Jeff:
Thanks, Please see my reply to David.
Bruce
Bruce Ratner, Ph.D.
The Significant Statistician™
(516) 791-3544
Statistical Predictive Analtyics -- www.DMSTAT1.com
Machine-Learning Data Mining and Modeling -- www.GenIQ.net
Jeff Newmiller wrote:
Coming from an Excel background, copying and pasting seems attractive, but it
does not create a reproducible record of what you did so it becomes quite
tiring and frustrating after some time has passed and you return to your
analysis.
Nitpick: you put the setdiff function in the row selection position, an error I
am sure Hadley did not recommend.
Since R is programmable, there are far more ways to select columns than just
setdiff. Since your description of desired features is vague, you are unlikely
to get the answer you would really like from your email. Some possibilities to
think about:
a) use regular expressions and grep or grepl to select by similar character patterns. E.g. all columns
including the the substring "value" or "key": grep( "key|value", names( dta ).
Possible to specify very complex selection patterns, but there are whole books on regular expressions, so you
can't expect to learn all about them on this R-specific mailing list.
b) use a separate csv file with a column listing each column name, and then one
column for each subset you want to define, using TRUE/FALSE values to include
or not include the column name identified. E.g.
# typically easier to manage in an external data file, online for example only
colsets <- read.csv( text=
"Colname,set1,set2
key,TRUE,TRUE
value1,TRUE,FALSE
value2,TRUE,FALSE
factor1,FALSE,TRUE
",header=TRUE,as.is=TRUE)
dta[ , colsets$set1 ]
Also your criteria of "clean listing" and "copy-pasteable" are likely mutually exclusive, depending
how you interpret them. You might be able to use dput to export a set of column names that can be re-imported
accurately, but you might not regard it as "clean" if you are thinking "readable".
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.