Thanks Marc,

Indeed my data is in the wrong class! I understand that it needs to be a matrix 
for barplot, but when I try to convert my list to a matrix, it doesnt seem to 
convert. How do I get the matrix() function (or array for that matter) working 
properly for me! 

The code below shows what I mean: 



from rpy import r
import numpy
 
r.png('output_r_test.png')
bars = numpy.array([[25,15,26,25,18],[45,32,28,12,45]])
r.print_(bars)
print r.class_(bars)

mat = r.matrix([25, 15, 26, 25, 18, 45, 32, 28, 12, 45],byrow=True,nrow=2)
r.print_(mat)
print r.class_(mat)

r.barplot(r.matrix(mat))

r.dev_off()

Output:

[[1]]
[1] 25 15 26 25 18

[[2]]
[1] 45 32 28 12 45

list
[[1]]
[1] 25 15 26 25 18

[[2]]
[1] 45 32 28 12 45

list
Traceback (most recent call last):
  File "C:\r_test\test.py", line 13, in <module>
    r.barplot(r.matrix(mat))
rpy.RPy_RException: Error in -0.01 * height : non-numeric argument to binary 
operator

 Thanks for your help,

 

Krysta

 


> Date: Fri, 15 May 2009 19:51:05 -0500
> From: larsen...@gmail.com
> To: rpy-list@lists.sourceforge.net
> Subject: Re: [Rpy] Barplot Error: rpy.RPy_RException: Error in -0.01 * height 
> : non-numeric argument to binary operator
> 
> > Traceback (most recent call last):
> >   File "r_test.py", line 70, in ?
> >     r.barplot(bars, beside = "TRUE" )
> > rpy.RPy_RException: Error in -0.01 * height : non-numeric argument to binary
> > operator
> 
> Your Numeric array is being converted into a list.
> 
> >>> from rpy import r
> >>> import Numeric
> >>> r.print_(bars)
> [[1]]
> [1] 25 15 26 25 18
> 
> [[2]]
> [1] 45 32 28 12 45
> 
> [[25, 15, 26, 25, 18], [45, 32, 28, 12, 45]]
> >>> r.is_list(bars)
> True
> 
> How about-->
> 
> r.barplot(r.matrix([25, 15, 26, 25, 18, 45, 32, 28, 12, 
> 45],byrow=True,nrow=2))
> 
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables 
> unlimited royalty-free distribution of the report engine 
> for externally facing server and web deployment. 
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> rpy-list mailing list
> rpy-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rpy-list

_________________________________________________________________
Looking for a fresh way to share photos? Download the new Windows Live 
Messenger!
http://download.live.com
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to