Duncan Murdoch <murdoch.duncan <at> gmail.com> writes: > > On 13-02-10 4:06 PM, David Romano wrote: > > Hi everyone, > > > > I ran into the issue below while trying to execute a command of the form > > > > apply(list.names,1, function(x) F(favorite.list$x) ) > > > > where list.names is a character vector containing the names of the elements > > of favorite.list and F is some function defined on a list element. > > > > Namely, the $ operator doesn't treat the string variable 'x' as the string > > it represents, so that, e.g.
[snip] > You can use names with [[, e.g. > > ll[[name]] > > will work in your example. You can see more details in the help topic > help("$"), in the section "Recursive (list-like) objects". > > Duncan Murdoch > > I nominate this issue as a candidate for an R FAQ entry. There's at least one question on StackOverflow about it: http://stackoverflow.com/questions/14123761/recursive-lists I think I've seen more but I can't find them right now (it's a little hard to search on "$" and "[[") ... ______________________________________________ R-help@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.