Li, Aiguo (NIH/NCI) [C]
2007-Mar-06 21:02 UTC
[R] Subseting data frame based on column names
Hello all, I have a data frame containing 170 columns and would like to generate a new data frame containing all rows but only 67 columns selected according to column names. How can I do this? Thanks in advance, AG Lee [[alternative HTML version deleted]]
Li, Aiguo (NIH/NCI) [C] wrote:> Hello all, > > > > I have a data frame containing 170 columns and would like to generate a > new data frame containing all rows but only 67 columns selected > according to column names. How can I do this?For date.frame "d" and column names in vector "cn": d[,cn] Uwe Ligges> > > Thanks in advance, > > > > AG Lee > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Use the subset function and the select argument of that function to specify the columns. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at intermountainmail.org (801) 408-8111> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Li, > Aiguo (NIH/NCI) [C] > Sent: Tuesday, March 06, 2007 2:02 PM > To: r-help at stat.math.ethz.ch > Subject: [R] Subseting data frame based on column names > > Hello all, > > > > I have a data frame containing 170 columns and would like to > generate a new data frame containing all rows but only 67 > columns selected according to column names. How can I do this? > > > > Thanks in advance, > > > > AG Lee > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >