[R] conversion

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Tue Jun 28 23:30:11 CEST 2005



Anna Oganyan wrote:
> Dear List,
> How can I convert a list with elements being character strings, like: 
> "c(1,2,3,4)", “c(1,3,4,2) … to a list with elements as numerical 
> vectors: c(1,2,3,4), c(1,3,4,2)…?
> Thanks!
> Anna
> 

Try:

x <- list("c(1,2,3,4)", "c(1,3,4,2)")
lapply(x, function(x) eval(parse(text = x)))

HTH,

--sundar




More information about the R-help mailing list