William Hudspeth wrote:
> Hello,
> 
> I am trying to use rpy to plot a histogram from data residing inside of
> a data.frame:
> 
> Normally, from the R prompt, I would use something like this:
> 
> hist(dust_frame$temp_density_raster)
> 
> The documentation indicates that the R function '$' can be accessed with
> something like this:
> 
> r['$']
> 
> but it is unclear how I would use it in the hist function above.

Really? That sounds funny to me - which bit of the documentation do you 
mean, maybe it needs improving.

> Any help would be greatly appreciated. I am using the R 'sp' and
> 'spgrass6' libraries to copy a GRASS GIS raster into R, and am then
> trying to use the raster grid values to plot, etc.
> 
> Bill

I thought $ was more of a syntax thing than a "function", but anyway...

I'm guessing you want to access the "temp_density_raster" sub-property 
of the dataframe "dust_frame" by doing:

hist(dust_frame$temp_density_raster)

When a dataframe is converted by rpy into a python object, you should 
get a dictionary where one of the keys should be "temp_density_raster". 
i.e. try dust_frame["temp_density_raster"] in python.

import rpy
...
rpy.r.hist(dust_frame['temp_density_raster'])

However, a word of warning, if you need to pass the dataframe to any R 
functions, you should read up about rpy's conversion settings... the 
catch is that the conversion from R dataframe to python dictionary is 
lossy and therefore one way.

Good luck

Peter


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to