如果我这样做,我会得到正确的结果:
a <- c("10","28","3")
which(as.numeric(a) == min(as.numeric(a)))
[1] 3
但是如果向量中有NA,那就有问题了
a <- c("10","28","3","NA")
which(as.numeric(a) == min(as.numeric(a)))
integer(0)
Warning messages:
1: In which(as.numeric(a) == min(as.numeric(a))) :
NAs introduced by coercion
2: In which(as.numeric(a) == min(as.numeric(a))) :
NAs introduced by coercion