问题如下:
数据来自多个样本,最后一列代表样本编号,读入数据如下
> data<-read.table("ex5-10.txt",head=F)
> data<-data[,2:6]
> data
V2 V3 V4 V5 V6
1 6.0 -11.5 19 90 1
2 -11.0 -18.5 25 -36 3
3 90.2 -17.0 17 3 2
4 -4.0 -15.0 13 54 1
5 0.0 -14.0 20 35 2
6 0.5 -11.5 19 37 3
7 -10.0 -19.0 21 -42 3
8 0.0 -23.0 5 -35 1
9 20.0 -22.0 8 -20 3
10 -100.0 -21.4 7 -15 1
11 -100.0 -21.5 15 -40 2
12 13.0 -17.2 18 2 2
13 -5.0 -18.5 15 18 1
14 10.0 -18.0 14 50 1
15 -8.0 -14.0 16 56 1
16 0.6 -13.0 26 21 3
17 -40.0 -20.0 22 -50 3
现在如果想把每个样本的数据筛选出来并分开储存应该怎么做呢?
试过
> data3<-data[data[,5]>2,]
> data3
V2 V3 V4 V5 V6
[1,] " -11.0" "-18.5" "25" "-36" "3"
[2,] " 0.5" "-11.5" "19" " 37" "3"
[3,] " -10.0" "-19.0" "21" "-42" "3"
[4,] " 20.0" "-22.0" " 8" "-20" "3"
[5,] " 0.6" "-13.0" "26" " 21" "3"
[6,] " -40.0" "-20.0" "22" "-50" "3"
输出的就不是数值了==
而且
> data[data[,5]=1,]
错误: 意外的'='在"data[data[,5]="里
“=”会报错
求指导呵,有木有高手有比较好的解决办法?