Re: [R] Converting a character string into an object variable

From: Benilton Carvalho <bcarvalh_at_jhsph.edu>
Date: Thu, 31 Jan 2008 23:35:20 -0500

assign(paste("V", i, sep=""), input.value[i])

b

On Jan 31, 2008, at 11:28 PM, Brant Inman wrote:

> R-helpers:
>
> Assume that I want to create a series of sequentially named R
> objects. For
> example, I might want to call these objects V1, V2, V3 ... V50. To
> do this,
> I thought of some sort of looping function like:
>
> input.value <- seq(1:50) * 3
> for(i in 1:50){
> paste("V", i, sep="") <- input.value[i]
> }
>
>
> Of course this loop will not work since the paste function returns a
> character string that cannot be a variable. How can I construct a
> loop to
> create sequential variables and assign a value to them in the same
> spirit of
> the loop above?
>
> Brant Inman
> Mayo Clinic
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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.



R-help_at_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. Received on Fri 01 Feb 2008 - 04:44:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 01 Feb 2008 - 05:30:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive