检测矢量中的异常值并绘制热图

时间:2015-09-02 11:36:45

标签: r

如何检测向量中的异常值?

例如,我有以下向量

color<-c("green","green","green","green","green","red","blue")
size<-c("big","small","big","big","big","small","medium")

对于每个矢量我想检测异常值并绘制热图

  • color异常值位于第6和第7位
  • size异常值位于2,6,7

1 个答案:

答案 0 :(得分:0)

这样的东西
color <- c("green","green","green","green","green","red","blue")
tt <- table(color)
names(tt)[tt<2]   ## values with frequency < 2
## 'blue', 'red'
ptt <- prop.table(tt)
names(ptt)[ptt<0.2]  ## values with frequency < 20%
## 'blue', 'red'