Jeff Gentry wrote: > Hi there ... > > I was looking to work with some of the Bioconductor annotation packages > directly in Python and came across Rpy2.
Good to see Bioconductor veterans here ! ;-) Rpy2 should/will do more with BioC (but more some time later). > The first problem is just one of > inexperience, I'm probably doing things all wrong and that could be the > source of my issue :) I did just notice something odd: > > t = robjects.r('get("1000_at", hgu95av2SYMBOL)') >>>> t > <RVector - Python:0x2aaab0e9ca70 / R:0x233c208> >>>> t[0] > 'MAPK3' > > So far so good. > > t = robjects.r('get("1017_at", hgu95av2SYMBOL)') > ## note that in R, this returns NA >>>> t > <RVector - Python:0x2aaab0e9cb90 / R:0x207dfc8> >>>> t[0] > True > > > Is this expected behavior (True replacing NA)? > Definitely not. This is a bug. I am also getting: >>> robjects.r('NA')[0] True > Also, while I'm here, is there a way to skip the intermediate step, ie > have the singular Python object returned instead of an RVector? Two things: 1) To a large extent, there is no scalar value in R, only length-one vectors. For example, in R: > length(NA) [1] 1 2) The RVector is actually a rabbit-hole leading to the R world. The values are only copied / becoming Python objects when accessed through the '[' operator. For automagic subsetting of length-one vectors, you can try tweaking the robjects-level converter like shown here: http://rpy.sourceforge.net/rpy2/doc/html/robjects_convert.html#a-simple-example Thanks for the bug report, L. > Thanks > -J > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > rpy-list mailing list > rpy-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rpy-list ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list