>>> import rpy
>>> x = [5.05, 6.75, 3.21, 2.66]
>>> y = [1.65, 26.5, -5.93, 7.96]
>>> z = [1.65, 2.64, 2.64, 6.95]
>>> print rpy.r.cor(x, y, method="spearman")
0.4
>>> print rpy.r.cor(x, z, method="spearman")
-0.632455532034
>>> print rpy.r.cor(x, y, method="kendall")
0.333333333333
>>> print rpy.r.cor(x, z, method="kendall")
-0.547722557505
|
(asdf:oos 'asdf:load-op :rcl)
(r:r-init)
(let ((x '(5.05 6.75 3.21 2.66))
(y '(1.65 26.5 -5.93 7.96))
(z '(1.65 2.64 2.64 6.95)))
(list
(r:r "cor" x y :method "spearman")
(r:r "cor" x z :method "spearman")
(r:r "cor" x y :method "kendall")
(r:r "cor" x z :method "kendall")))
=> (0.4d0 -0.6324555320336759d0
0.33333333333333337d0 -0.5477225575051661d0)
|
(asdf:oos 'asdf:load-op :rcl)
(r:r-init)
(r:enable-rcl-syntax)
(let ((x '(5.05 6.75 3.21 2.66))
(y '(1.65 26.5 -5.93 7.96))
(z '(1.65 2.64 2.64 6.95)))
(list
[cor x y :method "spearman"]
[cor x z :method "spearman"]
[cor x y :method "kendall"]
[cor x z :method "kendall"]))
=> (0.4d0 -0.6324555320336759d0
0.33333333333333337d0 -0.5477225575051661d0)
|
from rpy import *
import math
x = range(0, 10)
y1 = [ 2*i for i in x ]
y2 = [ math.log(i+1) for i in x ]
xlabels = [ "#%d" % (i,) for i in x ]
outfile = "somefile.ps"
r.postscript(outfile, paper='letter')
r.plot_default(x, y1, col="blue", type="o")
r.points(x, y2, col="red", type="o")
r.axis(1, at = x, label=xlabels, lwd=1, cex_axis=1.15)
r.title("My Plot")
r.dev_off
|
(asdf:oos 'asdf:load-op :rcl)
(r:r-init)
(defun test-plot (&optional (file-type :pdf) (file "/tmp/test"))
(let* ((x (loop for i from 0 below 10 collect i))
(y1 (mapcar (lambda (x) (* x 2)) x))
(y2 (mapcar (lambda (x) (log (1+ x))) x))
(labels (mapcar (lambda (x) (format nil "~R" x)) x)))
(r:with-device (file file-type)
(r:r "plot.default" x y1 :xlab "horizontal" :ylab "vertical"
:col "blue" :type "o" :axes nil)
(r:r "points" x y2 :col "red" :type "o")
(r:r "axis" 1 :at x :label labels :lwd 1 :cex.axis 0.75)
(r:r "axis" 2)
(r:r "box")
(r:r "title" "Plotting from Common Lisp"))))
|
(asdf:oos 'asdf:load-op :rcl)
(r:r-init)
(r:enable-rcl-syntax)
(defun test-plot (&optional (file-type :pdf) (file "/tmp/test"))
(let* ((x (loop for i from 0 below 10 collect i))
(y1 (mapcar (lambda (x) (* x 2)) x))
(y2 (mapcar (lambda (x) (log (1+ x))) x))
(labels (mapcar (lambda (x) (format nil "~R" x)) x)))
(r:with-device (file file-type)
[plot.default x y1 :xlab "horizontal" :ylab "vertical"
:col "blue" :type "o" :axes nil]
[points x y2 :col "red" :type "o"]
[axis 1 :at x :label labels :lwd 1 :cex.axis 0.75]
[axis 2]
[box]
[title "Plotting from Common Lisp"])))
|