Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Embryonic documentation for the RPy2 interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelCharpentier committed Dec 12, 2015
1 parent e503295 commit b4e9773
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion 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 .
Expand Down Expand Up @@ -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)
"""

##########################################################################
Expand Down

0 comments on commit b4e9773

Please sign in to comment.