On Thu, 13 Apr 2006, Chad Reyhan Bhatti wrote:

> Hello,
>
> I am creating a number of objects that I wish to have a common name with
> an index such as x1, x2, x3, ... I would like to do everyting in a loop to
> make the code compact and minimize the probability of an error by typo.

see FAQ 7.21 (including the suggestion not to do this).

        -thomas


> A test problem may look like
>
> for (j in 1:10){
>       as.symbol(paste("x",j,sep="")) <- j;
> }
>
> which ideally would produce x1 = 1, ... x10 = 10.  However, this does not
> work.
>
>> as.symbol(paste("x",1,sep="")) <- 2
> Error: Target of assignment expands to non-language object
>>
>
> Any help?
>
> Thanks,
>
> Chad R. Bhatti
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

Thomas Lumley                   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]       University of Washington, Seattle

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to