2008/6/25 Sean Davis <[EMAIL PROTECTED]>:
> First, Laurent, I am giving rpy2 a try and REALLY like what I see so
> far.  It is very much more intuitive, both from the point-of-view of
> an R programmer as well as for python programmers.
>
> Data frames are very nice R data structures, so I would like to
> capitalize on them and the changes included in rpy2 as much as
> possible.  So, how can I access the members of y (the data.frame)?  If
> one uses list subsetting, the values are actually reversed.  I figured
> out that y.getNames() will return the names of z, which I can then use
> to determine the list position.  Is there a way to do this with the
> column names directly?
>
> In [34]: z = ro.r['data.frame'](x=ro.r.c(1,2,3,4),y=ro.r.c(5,6,7,8))
>
> In [35]: z
> Out[35]:
> structure(list(y = 5:8, x = 1:4), .Names = c("y", "x"), row.names = c(NA,
> -4L), class = "data.frame")
>
> In [36]: z[0]
> Out[36]: 5:8
>
> In [37]: z[0][1]
> Out[37]: 6
>
> In [38]: z.getNames()
> Out[38]: c("y", "x")
>


z.subset('y')
returns a list, because data.frames are R lists, and R lists are
recursive structures.

z.subset('y')[0]
should make it.

The method "subset" mimics R's "[". There is probably the need for a
counterpart to R's "[[".

There will also be a proper class for data.frame (but that will be in July).


L.



> Thanks,
> Sean
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> rpy-list mailing list
> rpy-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rpy-list
>

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to