Documentation for rpy2 — rpy2 3.5.13 documentation (original) (raw)
The first section contains a quick introduction, as well as how to get started (requirements, install rpy2). This should be the natural place to start if you are new to R, or rpy2. Hints for porting existing code to a newer version of rpy2 are also given.
- Getting started
- Overview
* Background
* Installation
* Contents
* Design notes
* Acknowledgements - Introduction to rpy2
* Getting started
* R packages
* The r instance
* R vectors
* Calling R functions
* Getting help
* Examples - Using rpy2 in notebooks
* Data Import
* Graphics - R and pandas data frames
* From pandas to R
* From R to pandas
* Date and time objects - dplyr in Python
- Overview
- Porting code to rpy2
The high-level interface in rpy2 is designed to facilitate the use of R by Python programmers. R objects are exposed as instances of Python-implemented classes, with R functions as bound methods to those objects in a number of cases. This section also contains an introduction to graphics with R: trellis (lattice) plots as well as the grammar of graphics implemented in ggplot2 let one make complex and informative plots with little code written, while the underlying_grid_ graphics allow all possible customization is outlined.
- High-level interface
- The robjects package
* Overview
* r: the instance of R
* R objects
* Environments
* Functions
* Formulae
* R packages
* Working with R’s OOPs
* Object serialization
* R language
* Class diagram - Vectors and arrays
* Vector
* Creating vectors
* Extracting items
* Assigning items
* Missing values
* Operators
* Names
* Array
* Matrix
* DataFrame - R help
* Querying on aliases
* Package documentation
* Documentation page - Mapping rpy2 objects to arbitrary python objects
* Protocols
* Conversion - Interoperability with pandas
* R and pandas data frames - Graphics
* Introduction
* Package lattice
* Package ggplot2
* Package grid - DataFrames and dplyr
* dplyr
* dplyr in Python
* tidyr
* tidyr in Python
- The robjects package
R is often used in a read-eval-print loop (REPL), where interactivity is important. Utilities are available in rpy2.interactive.
Users of the Python signature numerical package numpy
can continue using the data structures they are familiar with, and share objects seamlessly with R.
A lower-level interface, closer to R’s C-level API, is available. It can be used when performance optimization is needed, or when extensions to the high-level interface are developped.
- Low-level interface
- Overview
* Initialization
* R space and Python space
* Pass-by-value paradigm
* Parsing and evaluating R code
* Calling Python functions from R - Interactive features
* I/O with the R console
* Processing interactive events - Multithreading
- Classes
* Sexp
* R arrays (vectors) inherit from SexpVector
* SexpEnvironment
* Functions
* SexpS4
* SexpExtPtr - Class diagram
- Misc. variables
* R types
- Overview
- Memory management and garbage collection
Finally, the documentation covers the subpackage with R-like Python classes and functions, callback functions, as well as compatibility with rpy-1.x. and benchmarks.
The list of changes across versions can be helpful when upgrading to a newer version of rpy2.