Gonçalo Ferraz
2008-Jan-27 13:42 UTC
[R] calling a list element from a list name passed to a function
Hi, 'true_name' is a list of numerical, matrix, and text items I do pass_name <- "true_name" and pass the name of the list to a function so that the character class variable 'passed_name' contains the name of the list called 'true_name' Inside the function, how can I get a specified element from the list? For example, if I want to get true_name$month How do I get that item with the passed name? Thank you for any help! Gon?alo
Gabor Grothendieck
2008-Jan-27 14:05 UTC
[R] calling a list element from a list name passed to a function
Its a FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-turn-a-string-into-a-variable_003f On Jan 27, 2008 8:42 AM, Gon?alo Ferraz <gferraz29 at gmail.com> wrote:> Hi, > > 'true_name' is a list of numerical, matrix, and text items > > I do > > pass_name <- "true_name" > > and pass the name of the list to a function so that the character > class variable 'passed_name' contains the name of the list called > 'true_name' > > Inside the function, how can I get a specified element from the list? > For example, if I want to get > > true_name$month > > How do I get that item with the passed name? > > Thank you for any help! > > Gon?alo > > ______________________________________________ > 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. >