[R] How to turn a string into a variable name ?

Erik Iverson iverson at biostat.wisc.edu
Fri Mar 14 05:35:31 CET 2008


You may be looking for the get function.

See ?get

Ng Stanley wrote:
> Hi,
> 
> For example,
> 
> natural_nums <- 1:10
> even_nums <- seq(2,10, by = 2)
> types <- c("natural_nums", "even_nums")
> 
> What functions can be performed on types[1] to turn it into a variable name
> and not a string ?
> 
> 	[[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.



More information about the R-help mailing list