Skip to content
Prev 278488 / 398503 Next

Error: invalid type(list) for variable when using lm()

Le vendredi 25 novembre 2011 ? 00:02 -0800, Dhaynes a ?crit :
The 'formula' argument of lm doesn't take actual values, but variable
names. So you need to create vectors containing your data, or pass a
data frame with these vectors are columns. So, going the latter way :
df <- data.frame(a=myarray[1,1,1:3], b=myarray[1,2,1:3])
lm(a ~ b, data=df)

or in one step
lm(a ~ b, data=data.frame(a=myarray[1,1,1:3], b=myarray[1,2,1:3]))


Regards