index the columns to select lets say you want to select a set of colmns 2,4,6,8 Try something like this. (not run) mycols <- c(2,4,6,8) select(mydata[ , mycols] , mdata$x == 3) John Kane Kingston ON Canada
> -----Original Message----- > From: bcrom...@utk.edu > Sent: Tue, 11 Jun 2013 09:18:25 -0700 (PDT) > To: r-help@r-project.org > Subject: [R] assigning global columns selection for all subset functions > in script > > How do I let R know that I always want to select the same columns in my > subset functions (below), so that I don't have to keep copy/pasting the > same > selection? (thanks) > devUni2 <- subset(devUni1, dind02 != 52, > select=c(paidhre,earnhre,earnwke,uhourse,hourslw,otc,ind02,dind02,occ00,docc00,lfsr94,class94,relref95,smsastat,state,weight,year)) > devUni3 <- subset(devUni2, lfsr94 == 1 | lfsr94 == 2 , > select=c(paidhre,earnhre,earnwke,uhourse,hourslw,otc,ind02,dind02,occ00,docc00,lfsr94,class94,relref95,smsastat,state,weight,year)) > devUni4 <- subset(devUni3, class94 < 6 , > select=c(paidhre,earnhre,earnwke,uhourse,hourslw,otc,ind02,dind02,occ00,docc00,lfsr94,class94,relref95,smsastat,state,weight,year)) > devUni5 <- subset(devUni4, relref95 < 10 | relref95 ==13 | relref95 > >=14, > select=c(paidhre,earnhre,earnwke,uhourse,hourslw,otc,ind02,dind02,occ00,docc00,lfsr94,class94,relref95,smsastat,state,weight,year)) > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/assigning-global-columns-selection-for-all-subset-functions-in-script-tp4669252.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org 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. ____________________________________________________________ FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! ______________________________________________ R-help@r-project.org 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.