> Data2<-cbind(c("ETDG","EDJG","METW","TDBT","EITC"),c(1,5,3,4,2))
> Data2
> [,1] [,2]
[1,] "ETDG" "1"
[2,] "EDJG" "5"
[3,] "METW" "3"
[4,] "TDBT" "4"
[5,] "EITC" "2"
我正在编码和R我希望消除上面数组中的所有行,第一列中的条目以字母E开头,我想一次完成所有这些。有没有一种简单的方法来实现这一目标?
答案 0 :(得分:2)
Data2[toupper(substr(Data2[,1],1,1)) != "E",]
答案 1 :(得分:2)
Data2 <- Data2[!grepl("^E",Data2[,1]),]