[R] calling a list element from a list name passed to a function

Gabor Grothendieck ggrothendieck at gmail.com
Sun Jan 27 15:05:28 CET 2008


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.
>



More information about the R-help mailing list