From b4e97738e0988f5e673347e71479b5fb2a37b879 Mon Sep 17 00:00:00 2001 From: Emmanuel Charpentier Date: Sat, 12 Dec 2015 22:03:42 +0100 Subject: [PATCH] Embryonic documentation for the RPy2 interface. --- src/sage/interfaces/r.py | 55 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/src/sage/interfaces/r.py b/src/sage/interfaces/r.py index 964d93e0f43..7e1d032dd43 100644 --- a/src/sage/interfaces/r.py +++ b/src/sage/interfaces/r.py @@ -1,5 +1,16 @@ r""" -Interface to R +Interfaces to R + +This is the reference to the Sagemath R interface, usable from any +Sage program. + +The %r interface creating an R cell in the sage +notebook is decribed in the Notebook manual. + +The %R and %%R interface creating an R line or an R cell in the +Jupyter notebook are briefly decribed at the end of this page. This +documentation will be expanded and placed in the Jupyter notebook +manual when this manual exists. The following examples try to follow "An Introduction to R" which can be found at http://cran.r-project.org/doc/manuals/R-intro.html . @@ -191,12 +202,54 @@ through Sage. For more information see the documentation of r.plot() or r.png(). +THE JUPYTER NOTEBOOK INTERFACE (work in progress). + +The %r interface described in the Sage notebook manual is not useful +in the Jupyter notebook : it creates a inferior R interpreter which +cannot be escaped. + +The RPy2 library allows the creation of an R cell in the Jupyter +notebook analogous to the %r escape in command line or %r cell in a +Sage notebook. + +The interface is loaded by a cell containing the sole code : + +"%load_ext rpy2.ipython" + +After executon of this code, the %R and %%R magics are available : + +- %R allows the execution of a single line of R code. Data exchange is + possible via the -i and -o options. Do "%R?" in a standalone cell + to get the documentation. + +- %%R alows the execution in R of the whole text of a cell, with + similar options (do "%%R?" in a standalone cell for + documentation). + +A few important points must be noted : + +- The R interpreter launched by this interface IS (currently) + DIFFERENT from the R interpreter used br other r... functions. + +- Data exchanged via the -i and -o options have a format DIFFERENT + from the format used by the r... functions (RPy2 mostly uses arrays, + and bugs the user to use the pandas Python package). + +- R graphics are (beautifully) displayed in output cells, but are not + directly importable. You have to save them as .png, .pdf or .svg + files and import them in Sage for further use. + +In its current incarnation, this interface is mostly useful to +statisticians needing Sage for a few symbolic computations but mostly +using R for applied work. + AUTHORS: - Mike Hansen (2007-11-01) - William Stein (2008-04-19) - Harald Schilly (2008-03-20) - Mike Hansen (2008-04-19) +- Emmanuel Charpentier (2015-12-12, RPy2 interface) """ ##########################################################################