This turns out to be quite easy...
Given:
> head(data)
inst a1 a2 a3 a4 a5 a6 a7 a8 escore
11 1 1 0 1 1 0 0 0 4
21 0 1 0 0 0 0 0 0 1
31 1 0 0 1 0 1 1 1 2
41 0 1 0 0 0 1 0 0 1
You can use grep on the names of the columns in d
thanks very much for the quick and accurate response!
Rnewb
--
View this message in context:
http://www.nabble.com/getting-variables-based-on-name-tp25725837p25726184.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.o
I have a file like this:
a1,a2,a3,b1,b2,b3
1,2,3,4,5,6
0,1,2,3,4,5
...
In interactive command-line R, I type
data<-read.table('file.txt', sep=',', header=TRUE)
I then want to get all the columns which start with the letter a. For this
particular file, I can the type:
data[1:3]
What if i don
This turns out to be quite easy...
Given:
> head(data)
inst a1 a2 a3 a4 a5 a6 a7 a8 escore
11 1 1 0 1 1 0 0 0 4
21 0 1 0 0 0 0 0 0 1
31 1 0 0 1 0 1 1 1 2
41 0 1 0 0 0 1 0 0 1
You can use grep on the names of the columns in d
4 matches
Mail list logo