I try to perform a simple
d = data.frame(replicate(6,rnorm(6)))
colnames(d) = as.character(0:5)
#Error in model.frame.default(formula = d[1, ] ~ colnames(d), drop.unused.levels = TRUE) :
#invalid type (list) for variable 'd[1, ]'
lm(columnA ~ columnB, data = mydata)
I have to make some assumptions on what you plan to do, as you are not actively clarifying it.
I am assuming you want a different, independent regression line for each row of your data frame. In other words, you have multiple response (one per row), but a common covariate:
x <- 1:ncol(d) - 1
Thus, you can do
fit <- lm(t(d) ~ x) #Call: #lm(formula = t(d) ~ x) #Coefficients: # [,1] [,2] [,3] [,4] [,5] [,6] #(Intercept) 0.23133 0.48307 0.07867 0.62308 0.71174 0.89866 #x 0.02964 -0.30077 -0.05160 0.06321 -0.17155 -0.43689
fit is not a standard "lm" object, but "mlm" (multiple linear models). The coefficient matrix you see above, has each column associated to each response.