[IPython-dev] R inside IPython (notebook, qtconsole or regular terminal)
Fernando Perez
fperez.net at gmail.com
Mon Jun 4 20:31:47 EDT 2012
Hi folks,
thanks to Jonathan Taylor (and those who contributed with review),
we've just merged this PR:
https://github.com/ipython/ipython/pull/1780
that lets you seamlessly use R from any IPython client. This is what
it looks like in the notebook:
http://i.imgur.com/ShKEz.png
but you can equally use it from a terminal:
In [5]: X = np.array([0,1,2,3,4])
In [6]: Y = np.array([3,5,4,6,7])
In [7]: %load_ext rmagic
In [8]: %%R -i X,Y -o XYcoef
...: XYlm = lm(Y~X)
...: XYcoef = coef(XYlm)
...: print(summary(XYlm))
...:
Call:
lm(formula = Y ~ X)
Residuals:
1 2 3 4 5
-0.2 0.9 -1.0 0.1 0.2
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.2000 0.6164 5.191 0.0139 *
X 0.9000 0.2517 3.576 0.0374 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.7958 on 3 degrees of freedom
Multiple R-squared: 0.81, Adjusted R-squared: 0.7467
F-statistic: 12.79 on 1 and 3 DF, p-value: 0.03739
In [9]: XYcoef
Out[9]: array([ 3.2, 0.9])
We also have an octave one coming
(https://github.com/ipython/ipython/pull/1849) by Stefan, as well as
magics to access the shell and save files in the notebook server
(https://github.com/ipython/ipython/pull/1855).
I figured this group would particularly like the R one. Many thanks
to Jonathan for the patient work during the fairly detailed review we
had prior to merging!
Cheers,
f
More information about the IPython-dev
mailing list