[R] function similar to "get" that works for both an object, and elements of an object?

Gabor Grothendieck ggrothendieck at gmail.com
Sat May 12 18:11:29 CEST 2007


Try:

get('tempdf')$a

get('templist')$x


On 5/12/07, new ruser <newruser at yahoo.com> wrote:
> #Is there a single function similar to "get" that works for both an object, and elements of an object ?
> #(I want the function to be able to return objects, and/or the deeper elements of an object.)
>
> #(i.e. elements of a dataframe and/or list)?
>
> #e.g.
>
> tempdf = data.frame(a=c(4,5,6) , b=c(10,11,12) )
>
> templist= list(x=tempdf, y=c(1,2))
>
> get('tempdf') #works as desired
>
> get('tempdf$a') #retrusn errro message
>
> get('templist$x') #retrusn errro message
>
>
> ---------------------------------
> 8:00? 8:25? 8:40?  Find a flick in no time
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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