[R] Simple column selection question- which and character lists
eiverson at NMDP.ORG
Mon Aug 31 19:15:35 CEST 2009
1) Don't call your data.frame "data". I will call my "example" one "df".
2) If you want the columns NOT in names.species.bio.18, which is what you said, then the answer is:
df[!names(df) %in% names.species.bio.18]
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of AllenL
Sent: Monday, August 31, 2009 11:40 AM
To: r-help at r-project.org
Subject: [R] Simple column selection question- which and character lists
Seems simple but have tried multiple approaches, no luck.
I have a list of column names:
I want to select the column numbers which correspond to these names in my
+ 75 76
+In cols == names.species.bio.18 :
+ longer object length is not a multiple of shorter object length
So I get the first two hits and then it trips an error message.
What is >which doing? Why does it seem to have trouble with vectors of
My goal is to output the column names/indices which correspond to the
columns NOT in the above list, but that is simple once I can find out what
View this message in context: http://www.nabble.com/Simple-column-selection-question--which-and-character-lists-tp25226500p25226500.html
Sent from the R help mailing list archive at Nabble.com.
R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help