Shortcut using lm() in R for formula
It is possible to use a shortcut for formula in lm() m <- matrix(rnorm(100), ncol=5) lm(m[,1] ~ m[,2:5] here it would be the same as lm(m[,1] ~ m[,2] + m[,3] + m[,4] + m[,5] but in the case when variables are not of the same level (at least this is my assumption for now) this does not work and I get the error: Error in model.frame.default(formula = hm[, 1] ~ hm[, 2:4], drop.unused.levels = TRUE) : invalid type (list) for variable 'hm[, 2:4]' Data (hm): N cor.distance switches time 1 50 0.04707842 2 0.003 2 100 -0.10769441 2 0.004 3 200 -0.01278359 2 0.004 4 300 0.04229509 5 0.008 5 500 -0