new ruser
2007-May-12 16:05 UTC
[R] function similar to "get" that works for both an object, and elements of an object?
#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]]
Gabor Grothendieck
2007-May-12 16:11 UTC
[R] function similar to "get" that works for both an object, and elements of an object?
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.
>