In order to parse a list of variables to lm in R, first, you should make sure that your dataset is ready for modeling. To do so, you may need to perform some data preprocessing steps. Once the data is ready, you can use the following code to create a linear regression model using the variables listed in the variable list:
main.r322 chars12 lines
Here, we use the select function from the dplyr package to extract the variables listed in the variable list and store them in a new data frame data_new. Then, we use the lm function to create a linear regression model model using the extracted variables. The formula "y ~ ." indicates that y is the response variable and all other variables in the data frame should be used as predictors.
gistlibby LogSnag