On Tue, Mar 31, 2009 at 10:05 AM, Alina Sheyman <alina...@gmail.com> wrote:

> I'm running the following code
>
> numbers <- 1:50
> for (i in 1:50)
>
> assign(paste("model",numbers[i]),i)<-(lm(temp$Overall.Scaled.Score~temp$raw.score))
>

a) What is the purpose of numbers?  Why not write
     paste("model",i)
b) Why assign( ... ) <- ... ?  Don't you just want
         assign(paste("model",i),lm(temp$Overall.Scaledxxx))
c) Why are you assigning to variables named `model 1` etc. instead of making
a list of all the models? e.g.
      models <- sapply( 1:50, function(i) ... )

           -s



>
> where I want R to create 50 different models-1:50, but get the following
> error message
>
> "target of assignment expands to non-language object". I've tried it with
>  paste("model",numbers[i]))<-(lm(temp$Overall.Scaled.Score~temp$raw.score)
> and get the same error.
>
> Does anyone know what the problem is or whether there's a better way to get
> at what I'm trying to do?
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to