[R] extract columns using their names

About this list Date view Thread view Subject view Author view Attachment view

From: Adrian Dusa (adi@roda.ro)
Date: Fri 28 May 2004 - 00:19:35 EST


Message-id: <000c01c443f5$af212510$6901a8c0@roda.local>

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@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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:13 EST