0

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 which depends if output is satisfactory or not.

i like to know how to do this in R. Any help or even if someone can point to a previous thread will help.

user16789
  • 183
  • 1
  • 1
  • 3
  • what is the criteria for handful variable? can you give an example of your data? – bakyaw Nov 14 '12 at 13:44
  • 1
    FWIW, `lm` and `glm` will subset correct variables based on the formula specified. In such a case, no prior "cleaning" is needed. You can make a subset using `your.data[]` syntax, but we will need to know more about what is the criterion on which you select the variables, as pointed by @bakyaw. – Roman Luštrik Nov 14 '12 at 14:07

1 Answers1

0

If you want to just select several variables, and not the entire data frame (or table in SQL parlance), a simple way to do this is to just subset the data frame prior to running your set of procedures using the "subset" function, e.g

newdata <- subset(mydata, select=c(ID, Weight))

This will only pull 2 variables out of the "mydata" data frame (ID and Weight).

You can then change this statment every time your variables change.

BTW: Macro variable is a SAS term, are you converting something from SAS?

mnel
  • 113,303
  • 27
  • 265
  • 254
Ralph Winters
  • 297
  • 1
  • 5