Skip to content

Macro Variable in R

3 messages · SASandRlearn, John Kane, David Winsemius

#
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
____________________________________________________________
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:

            
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.
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.