[R] extract columns using their names
Adrian Dusa
adi at roda.ro
Thu May 27 16:19:35 CEST 2004
Hello,
Is there a way to extract multiple columns from a dataframe using their
names instead of their numbers?
Currently I use:
data2 <- data1[, c(1,3,9)]
And I am looking for something like
data2 <- data1[, c("XX","YY","ZZ")]
I use the same dataframe for many purposes, and I run codes that change
the order of the columns every time.
Many thanks,
Adrian
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adrian Dusa (adi at roda.ro)
Romanian Social Data Archive (www.roda.ro)
1, Schitu Magureanu Bd.
050025 Bucharest sector 5
Romania
Tel./Fax: +40 (21) 312.66.18\
+40 (21) 312.02.10/ int.101
More information about the R-help
mailing list