Output Regression statistics for each variable one at a time in R

后端 未结 3 1207
说谎
说谎 2021-01-15 11:35

I have a data frame that looks like this. names and number of columns will NOT be consistent (sometimes \'C\' will not be present, other times \"D\', \'E\', \'F\' may be pre

3条回答
  •  失恋的感觉
    2021-01-15 12:08

    As written in the comment: ?as.formula() is one solution. You could do sthg like:

    model = list()
    for(char in names(YABC)[-1]) {
      model[[char]] <- lm(as.formula(paste("Y ~ ", char)), YABC)
    }
    model
    

提交回复
热议问题