Re: [R] assigning a list item using a variable for a name

2011-03-22 Thread Joshua Wiley
Hi RSVP, On Tue, Mar 22, 2011 at 4:47 PM, RSVP wrote: > I have a list. > > my.list <- list(Tom=c(1,2,3), Dick=c(4,5,6), Harry=c(7,8,9)) > > I assign one of the names of the list to a variable. > > name <- "Harry" > > I can access the value of the list using the variable as follows: > >  eval(pars

[R] assigning a list item using a variable for a name

2011-03-22 Thread RSVP
I have a list. my.list <- list(Tom=c(1,2,3), Dick=c(4,5,6), Harry=c(7,8,9)) I assign one of the names of the list to a variable. name <- "Harry" I can access the value of the list using the variable as follows: eval(parse(text=paste("my.list$", name, sep=""))) [1] 7 8 9 But how do I change