Re: [R] for loop; lm() regressions; list of vectors - lapply - accolades and square brackets??

2010-03-31 Thread Driss Agramelal
Hello and thank you both for your answers! Dennis, I tried to simply run lm(a ~ b) after re-importing a as a matrix, but I get the following error message: Error in model.frame.default(formula = a ~ b, drop.unused.levels = TRUE) : invalid type (list) for variable 'a' so maybe I have to

Re: [R] for loop; lm() regressions; list of vectors - lapply - accolades and square brackets??

2010-03-31 Thread David Winsemius
On Mar 31, 2010, at 9:13 AM, Driss Agramelal wrote: Hello and thank you both for your answers! Dennis, I tried to simply run lm(a ~ b) after re-importing a as a matrix, but I get the following error message: Error in model.frame.default(formula = a ~ b, drop.unused.levels = TRUE)

Re: [R] for loop; lm() regressions; list of vectors - lapply - accolades and square brackets??

2010-03-31 Thread Peter Ehlers
Driss, David is right - you should include data/code. Nevertheless, the error you get suggests that what you call a matrix is in fact a data.frame; that's usually a crucial distinction. There are two things you might try: Dennis' way: lm(as.matrix(a) ~ b) David's way: for(i in

Re: [R] for loop; lm() regressions; list of vectors - lapply - accolades and square brackets??

2010-03-31 Thread Driss Agramelal
Peter, it works!!! Thanks a lot to all of you! Yes I mistook a data.frame for a matrix Now both David's and Dennis' solutions work! I am really a beginner with R, and I think it's a wonderful tool, but sometimes a little difficult to use only learning from the manuals and help files... I