I have over 300 variables in my table. I want to choose only a handful of those variables to run through many procedures. Lm(), glm() etc..i have over 10 procedures that i need to run those variables everytime. Those handful of variables can change everytime if output is satisfactory or not. I have done this in SAS. Now i need to know how to do this in R. Any help or even if someone can point to a previous thread will help. -- View this message in context: http://r.789695.n4.nabble.com/Macro-Variable-in-R-tp4649460.html Sent from the R help mailing list archive at Nabble.com.
Not a specific answer to your question but have you seen www.et.bs.ehu.es/~etptupaf/pub/R/RforSAS&SPSSusers.pdf. If you are just starting to use R it is a very handy reference on the differences and similarities among the packages. John Kane Kingston ON Canada> -----Original Message----- > From: sasandrlearn at gmail.com > Sent: Tue, 13 Nov 2012 18:06:08 -0800 (PST) > To: r-help at r-project.org > Subject: [R] Macro Variable in R > > I have over 300 variables in my table. I want to choose only a handful of > those variables to run through many procedures. Lm(), glm() etc..i have > over > 10 procedures that i need to run those variables everytime. Those handful > of > variables can change everytime if output is satisfactory or not. > > I have done this in SAS. Now i need to know how to do this in R. Any help > or > even if someone can point to a previous thread will help. > > > > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Macro-Variable-in-R-tp4649460.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.____________________________________________________________ GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at http://www.inbox.com/smileys Works with AIM?, MSN? Messenger, Yahoo!? Messenger, ICQ?, Google Talk? and most webmails
On Nov 13, 2012, at 6:06 PM, SASandRlearn wrote:> I have over 300 variables in my table. I want to choose only a handful of > those variables to run through many procedures. Lm(), glm() etc..i have over > 10 procedures that i need to run those variables everytime. Those handful of > variables can change everytime if output is satisfactory or not.How do you represent those variables? Are they only going to appear on the RHS of hte formula? If the LHS of the formula, say 'outcome', will remain the same and the variable names can be presented in a character vector drawn from a list, combvecs, you could do something like this: reslist <- list() for (vec in combvecs) { res1 <- lm(outcome ~ . , data=dat_table[ , c("outcome", vec) ] res2 <- glm(outcome ~ . , data=dat_table[ , c("outcome", vec) ] reslist <-c( reslist, list(res1, res2) ) You really should be offering test cases that resemble the structure of your problem.> > I have done this in SAS. Now i need to know how to do this in R. Any help or > even if someone can point to a previous thread will help.There are many threads that demonstrate how to use the formula() and as.formula() functions. The Posting Guide gives pointers on searching the Archives. You should also note that Nabble is not Rhelp and that your continued failure to include context will probably result in longer waits for replies than you might experience. -- David Winsemius, MD Alameda, CA, USA