Changes

Jump to navigation Jump to search
== R ==
 
<texcode>
\stoptext
</texcode>
 
<pre>
import rpy2.robjects as robjects
import rpy2.rinterface as rinterface
 
class density(object):
 
def __init__(self,samples,outpdf,w,h,kernel):
self.samples = samples
self.outpdf= outpdf
self.kernel = kernel
self.width=w
self.height=h
 
def run(self):
r = robjects.r
data = [int(k.strip()) for k in file(self.samples,'r').readlines()]
x = robjects.IntVector(data)
r.pdf(file=self.outpdf,width=self.width,height=self.height)
z = r.density(x,kernel=self.kernel)
#r.plot(z[0],z[1],xlab='',ylab='',xlim=robjects.IntVector([0,2**16-1]))
r.plot(z[0],z[1],xlab='',ylab='')
r['dev.off']()
 
 
if __name__ == '__main__' :
dens = density('u-random-int','test-001.pdf',10,7,'o')
dens.run()
</pre>
 
<!--[[Image:TestPIL.jpg]]-->

Navigation menu