On Wed, 2007-03-28 at 08:38 -0700, Brian Dolan wrote:
> Hello,
> 
> I would like to take the string
> 
> "mylist = list(a = 5, b = 7)"
> 
> and evaluate it as a list.  I have attempted to use parse and several
> other functions with no success.
> 
> Thanks for your time.


Not sure what combinations you may have tried, but here is a solution:

> ls()
character(0)

> eval(parse(text = "mylist <- list(a = 5, b = 7)"))

> ls()
[1] "mylist"

> mylist
$a
[1] 5

$b
[1] 7


HTH,

Marc Schwartz

______________________________________________
[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
and provide commented, minimal, self-contained, reproducible code.

Reply via email to