This is a quick hack that simply prepends %%R
to every cell and requires using the IPython R magic.
To make this work, run:
ipython profile create rkernel
Then put the accompanying rkernel.py
file in the startup/
directory of the above profile directory, and run IPython with
ipython <app> --profile rkernel
where <app>
can be notebook
, qtconsole
, or nothing for the terminal client.
Written in 20 minutes by F. Perez, Ariel Rokem and Haoxing Zhang @ Stanford, Feb 19 2014.
Simple variable assignment:
a <- 1
a
[1] 1
Simple plots
X <- c(1,2,3)
Y <- c(4.5,5.7,8.1)
plot(X,Y)
print(summary(lm(Y~X)))
Call: lm(formula = Y ~ X) Residuals: 1 2 3 0.2 -0.4 0.2 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.5000 0.7483 3.341 0.185 X 1.8000 0.3464 5.196 0.121 Residual standard error: 0.4899 on 1 degrees of freedom Multiple R-squared: 0.9643, Adjusted R-squared: 0.9286 F-statistic: 27 on 1 and 1 DF, p-value: 0.121