Following are some example of subsetting in R I have used recently.
> head(crystal)
V1 V2 V3 V4
1 1ACJ PHE120 290.980 289.101
2 1ACJ PHE153 307.673 283.814
3 1ACJ PHE155 296.153 89.152
4 1ACJ PHE186 311.606 292.186
5 1ACJ PHE187 298.920 270.613
6 1ACJ PHE197 66.678 323.351
>subset(crystal, crystal$V2=="PHE330" & grepl("^2A",crystal$V1))
http://www.ats.ucla.edu/stat/r/faq/subset_R.htm
http://stackoverflow.com/questions/2125231/subsetting-in-r-using-or-condition-with-strings
> head(crystal)
V1 V2 V3 V4
1 1ACJ PHE120 290.980 289.101
2 1ACJ PHE153 307.673 283.814
3 1ACJ PHE155 296.153 89.152
4 1ACJ PHE186 311.606 292.186
5 1ACJ PHE187 298.920 270.613
6 1ACJ PHE197 66.678 323.351
>subset(crystal, crystal$V2=="PHE330" & grepl("^2A",crystal$V1))
http://www.ats.ucla.edu/stat/r/faq/subset_R.htm
http://stackoverflow.com/questions/2125231/subsetting-in-r-using-or-condition-with-strings
No comments:
Post a Comment