[R] evaluating a vector of characters

Henrique Dallazuanna wwwhsd at gmail.com
Mon Jan 7 18:55:32 CET 2008


Try:
sapply(paste("Data$x", 1:3, sep=""), function(x)eval(parse(text=x)))

On 07/01/2008, Gregory Gentlemen <gregory_gentlemen at yahoo.ca> wrote:
> Dear R users,
>
> I'd like to evaluate a vector of characters. For example, say I have a data frame called Data including the field names x1, x2, x3, and I'd like to a list out of paste("Data$x", 1:3, sep=""). How can I get list to evaluate paste("Data$x", 1:3, sep="") as an R object rather than a string?
>
> Thanks in advance for you assistance.
> Gregory
>
>
> ---------------------------------
>
>         [[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.
>


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O




More information about the R-help mailing list