Revision: 543 http://rpy.svn.sourceforge.net/rpy/?rev=543&view=rev Author: lgautier Date: 2008-06-01 06:12:40 -0700 (Sun, 01 Jun 2008)
Log Message: ----------- - texinfo removed - more documentation Modified Paths: -------------- branches/rpy_nextgen/doc/source/conf.py branches/rpy_nextgen/doc/source/overview.rst branches/rpy_nextgen/doc/source/rinterface.rst branches/rpy_nextgen/doc/source/robjects.rst branches/rpy_nextgen/doc/source/rpy_classic.rst Removed Paths: ------------- branches/rpy_nextgen/doc/rpy.texi Deleted: branches/rpy_nextgen/doc/rpy.texi =================================================================== --- branches/rpy_nextgen/doc/rpy.texi 2008-06-01 12:04:10 UTC (rev 542) +++ branches/rpy_nextgen/doc/rpy.texi 2008-06-01 13:12:40 UTC (rev 543) @@ -1,639 +0,0 @@ -\input texinfo @c -*-texinfo-*- - [EMAIL PROTECTED] %**start of header [EMAIL PROTECTED] rpy.info [EMAIL PROTECTED] @RP2{} Reference Manual [EMAIL PROTECTED] %**end of header [EMAIL PROTECTED] Programming [EMAIL PROTECTED] -* RPy v2: (rpy2). RPy2, Python extension module for R. [EMAIL PROTECTED] direntry - [EMAIL PROTECTED] VERSIONno 2.0.0-dev - [EMAIL PROTECTED] Python -Python [EMAIL PROTECTED] macro - [EMAIL PROTECTED] RPy -RPy [EMAIL PROTECTED] macro [EMAIL PROTECTED] RPy2 -RPy2 [EMAIL PROTECTED] macro - [EMAIL PROTECTED] R -R [EMAIL PROTECTED] macro - [EMAIL PROTECTED] C -C [EMAIL PROTECTED] macro - [EMAIL PROTECTED] -This file documents @RPy2{} @value{VERSIONno} - -Copyright @copyright{} 2008 L.@: Gautier@ - -Permission is granted to make and distribute verbatim -copies of this manual provided the copyright notice and -this permission notice are preserved on all copies. - [EMAIL PROTECTED] -Permission is granted to process this file through TeX -and print the results, provided the printed document -carries a copying permission notice identical to this -one except for the removal of this paragraph (this -paragraph not being relevant to the printed manual). [EMAIL PROTECTED] ignore - -Permission is granted to copy and distribute modified -versions of this manual under the conditions for -verbatim copying, provided also that the sections -entitled ``Copying'' and ``GNU General Public License'' -are included exactly as in the original, and provided -that the entire resulting derived work is distributed -under the terms of a permission notice identical to this -one. - -Permission is granted to copy and distribute -translations of this manual into another language, -under the above conditions for modified versions, -except that this permission notice may be stated in a -translation approved by the Free Software Foundation. [EMAIL PROTECTED] ifinfo - [EMAIL PROTECTED] [EMAIL PROTECTED] @RPy2{} Reference Manual [EMAIL PROTECTED] (version @version{}) [EMAIL PROTECTED] Laurent Gautier [EMAIL PROTECTED] [EMAIL PROTECTED] 0pt plus 1filll -Copyright @copyright{} 2008 - -Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that -the sections entitled ``Copying'' and ``GNU General Public License'' -are included exactly as in the original, and provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. [EMAIL PROTECTED] titlepage - [EMAIL PROTECTED] [EMAIL PROTECTED] Top, Overview, (dir), (dir) [EMAIL PROTECTED] @RPy{} Reference Manual (version @version{}) - -This is the reference manual for @RPy{} version @version{}, a @Python{} -extension module for using the @R{} programming language. [EMAIL PROTECTED] ifnottex - [EMAIL PROTECTED] -* Preface:: -* Overview:: -* robjects:: -* rinterface:: -* Acknowledgements:: [EMAIL PROTECTED] menu - - [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] iftex - [EMAIL PROTECTED] Preface, Overview, Top, Top [EMAIL PROTECTED] Preface - -This presentation describes @RPy2{}, a close-to-complete rewrite of -the @RPy{} package. - -It is developped for R-2.7 (and is not expected to work -with a previous version), together with @Python{} 2.5. Compatibility -with @Python{} 2.4 is expected but not tested when writing -those lines. - [EMAIL PROTECTED] @asis [EMAIL PROTECTED] Walter Moreira, and Gregory Warnes -For the original @RPy{} and its maintainance through the years. -I realized through my work that it was then truly uncharted territories, -and that you got there first. [EMAIL PROTECTED] Alexander Belopolsky. -The contributed code of Alexander Belopolsky, who contributed -a first rewrite to @RPy{} is acknowledged. I have found great -inspiration in reading that code. [EMAIL PROTECTED] table - [EMAIL PROTECTED] Overview, , Preface, Top [EMAIL PROTECTED] Overview - - [EMAIL PROTECTED]://www.python.org, @Python{}} is a popular -all-purpose scripting language, while @uref{http://www.r-project.org, @R{}} -is a scripting language mostly popular for data analysis, statistics, and -graphics. - - -The @RPy{} project is an effort to have access to @R{} from within @Python{}, - -The @RPy{} code is initially inspired in RSPython, which is part of -the @uref{http://www.omegahat.org/RSPython, Omegahat project}. - [EMAIL PROTECTED] is inspired by @RPy{} and A. Belopolskys's contributions to @RPy. -Backward compatibility with @RPy{} is somewhat limited, but rinterface -is providing the basic blocks to re-implement @RPy{} if needed. - -FIXME: write a section about what changed - - - -The package is made of several elements: [EMAIL PROTECTED] @code [EMAIL PROTECTED] robjects -Higher-level interface, when ease-of-use matters most -(@xref{robjects}) - [EMAIL PROTECTED] rinterface -Low-level interface to R, when speed and flexibility -matter most (@xref{rinterface}). Here the programmer gets close -to @R{}'s C API, and can use R's function faster than within an R session. - [EMAIL PROTECTED] table - [EMAIL PROTECTED] robjects [EMAIL PROTECTED] robjects - [EMAIL PROTECTED] Overview -This module is intended for casual and general use. -Its aim is to abstracts some of the details and provide an -intuitive interface to R. - [EMAIL PROTECTED] ->>> import rpy2.robjects as robjects [EMAIL PROTECTED] example - [EMAIL PROTECTED] is written on the top of @code{rinterface}, and one -not satisfied with it could easily build one's own flavor of a [EMAIL PROTECTED]@R{} interface by modifying it. - - [EMAIL PROTECTED] Classes [EMAIL PROTECTED] @code [EMAIL PROTECTED] Robject -Parent class for @R{} objects. - [EMAIL PROTECTED] Rvector -An @R{} vector - [EMAIL PROTECTED] Renvironment -An @R{} environment. - [EMAIL PROTECTED] Rfunction -An @R{} function. [EMAIL PROTECTED] table - [EMAIL PROTECTED] R - -This class is currently a singleton, with -its one representation instanciated when the -module is loaded: - [EMAIL PROTECTED] ->>> robjects.r ->>> print(robjects.r) [EMAIL PROTECTED] example - -The instance can be seen as a window to an -embedded @R{} process. -Readers familiar with the ctypes module for @Python - [EMAIL PROTECTED] vectors: [EMAIL PROTECTED] ->>> pi = robjects.r.pi ->>> letters = robjects.r.letters [EMAIL PROTECTED] example - [EMAIL PROTECTED] functions: - [EMAIL PROTECTED] ->>> plot = robjects.r.plot ->>> dir = robjects.r.dir [EMAIL PROTECTED] example - -The evaluation of @R{} code in a string can also be performed -FIXME: (not yet implemented/tested) - [EMAIL PROTECTED] Robject - - [EMAIL PROTECTED] Rvector - -Outside functions, and environemnts, most of the objects -an @R{} user is interacting with are vector-like. -For example, this means that any scalar is in fact a vector -of length one. - -The class @code{Rvector} has a constructor: [EMAIL PROTECTED] ->>> x = robjects.Rvector(3) [EMAIL PROTECTED] example - -Operations on vectors: [EMAIL PROTECTED] @code [EMAIL PROTECTED] + -Add [EMAIL PROTECTED] - -Subtract [EMAIL PROTECTED] * -Multiply [EMAIL PROTECTED] / -Divide [EMAIL PROTECTED] table - -FIXME: -Indexing - -This class is using the class @code{rinterface.SexpVector} -(@xref{SexpVector}). - [EMAIL PROTECTED] Numpy - -Vectors can also be readily converted to Numpy arrays: [EMAIL PROTECTED] ->>> import numpy ->>> ltr = robjects.r.letters ->>> ltr_np = numpy.array(ltr) [EMAIL PROTECTED] example - - [EMAIL PROTECTED] Renvironment - [EMAIL PROTECTED] environments can be described to the @Python user as -an hybrid of a dictionary and a scope. - -The first of all environments is called the Global Environment, -that can also be referred to as the R workspace (@xref{globalEnv}). [EMAIL PROTECTED] ->>> globalEnv = robjects.globalEnv [EMAIL PROTECTED] example - -An @R{} environment in @RPy2{} can be seen as a kind of @Python{} -dictionnary. - -Assigning a value to a symbol in an environment has been -made as simple as assign a value to a key in a @Python{} -dictionary: [EMAIL PROTECTED] ->>> robjects.r.ls(globalEnv) ->>> globalEnv["a"] = 123 ->>> robjects.r.ls(globalEnv) [EMAIL PROTECTED] example - -Care must be taken when assigning objects into an environment -such as the Global Environment, as it can hide other objects -with an identical name. -For example [EMAIL PROTECTED] ->>> globalEnv["pi"] = 123 ->>> robjects.r.pi -123L [EMAIL PROTECTED] example - [EMAIL PROTECTED] ->>> robjects.r.rm("pi") ->>> robjects.r.pi -3.1415926535897931 [EMAIL PROTECTED] example - -This class is using the class @code{rinterface.SexpEnvironment} -(@xref{SexpEnvironment}). - -An environment is also iter-able, returning all the symbols -(keys) it contains: - [EMAIL PROTECTED] ->>> env = robjects.r.baseenv() ->>> len([x for x in env]) [EMAIL PROTECTED] example - - [EMAIL PROTECTED] Rfunction - [EMAIL PROTECTED] ->>> plot = robjects.r.plot ->>> rnorm = robjects.r.rnorm ->>> plot(rnorm(100), ylab="random") [EMAIL PROTECTED] example - -This class is using the class @code{rinterface.SexpClosure} -(@xref{SexpClosure}). - - [EMAIL PROTECTED] Mapping - -The mapping between low-level objects is performed by the -functions XXX and XXX. - -A developper can easily add his own mapping XXX. - [EMAIL PROTECTED] Examples - [EMAIL PROTECTED] ->>> import array - ->>> r = robjects.r - ->>> x = array.array('i', range(10)) ->>> y = r.rnorm(10) - ->>> r.X11() - ->>> r.par(mfrow=array.array('i', [2,2])) ->>> r.plot(x, y, ylab="foo/bar", col="red") - ->>> kwargs = {'ylab':"foo/bar", 'type':"b", 'col':"blue", 'log':"x"} ->>> r.plot(x, y, **kwargs) - ->>> m = r.matrix(r.rnorm(100), ncol=5) ->>> pca = r.princomp(m) ->>> r.plot(pca, main="Eigen values") ->>> r.biplot(pca, main="biplot") - ->>> if not r.require("GO")[0]: -... raise(Exception("Bioconductor Package GO missing")) -... - ->>> goItem = r.GOTERM["GO:0000001"] [EMAIL PROTECTED] example - [EMAIL PROTECTED] rinterface [EMAIL PROTECTED] rinterface - [EMAIL PROTECTED] Overview -A lower-level interface is provided for cases where -the use-cases addressed by @code{robjects} are not covered, -and for the cases where the layer in @code{robjects} -has an excessive cost on the performances. - [EMAIL PROTECTED] ->>> import rpy2.rinterface as rinterface [EMAIL PROTECTED] example - [EMAIL PROTECTED] initEmbeddedR [EMAIL PROTECTED] initEmbeddedR - -One has to initialize R before much can be done. -The function @code{initEmbeddedR} lets one initialize -the embedded R: [EMAIL PROTECTED] ->>> rinterface.initEmbeddedR() [EMAIL PROTECTED] example - -Initialization should only be performed once and in the case -of a second call to initEmbeddedR, to avoid unpredictable results -when using the embedded R, an exception is be fired. - -Parameters for the initialization are in the module varible [EMAIL PROTECTED] - [EMAIL PROTECTED] Rspace [EMAIL PROTECTED] @R{} space and @Python{} space - -When using the @RPy2{} package, two realms are co-existing: @R{} and @Python{}. - -The @code{Sexp_Type} objects can be considered as @Python{} shells pointing -to data stored and administered in the @R{} space. - - [EMAIL PROTECTED] globalEnv [EMAIL PROTECTED] globalEnv - -The global environment can be seen as the topmost environment, -and is in fact a list, that is a sequence, of environments. - -When an @R{} library (package in @R{}'s terminology) is loaded, -is it added to the existing sequence of environments. Unless -specified, it is inserted in second position. The first position -always remains attributed to the global environment -(FIXME: there is a bit of circulariry in this definition - check -how to present it a clear(er) way). -The library is said to be attached to the current search path. - [EMAIL PROTECTED] Sexp [EMAIL PROTECTED] Sexp - -Methods: [EMAIL PROTECTED] @code [EMAIL PROTECTED] typeof() -Type of the object [EMAIL PROTECTED] do_slot([name]) -Access attribute @code{name} for the object [EMAIL PROTECTED] table - [EMAIL PROTECTED] typeof [EMAIL PROTECTED] typeof - -The internal @R{} type in which an object is stored can be -accessed with the function @code{typeof}. - [EMAIL PROTECTED] ->>> letters.typeof() [EMAIL PROTECTED] example - -FIXME: talk about the all the types. - - [EMAIL PROTECTED] do_slot [EMAIL PROTECTED] do_slot - [EMAIL PROTECTED] objects can be geiven attributes. In @R{} the function [EMAIL PROTECTED] lets one access attribute, while called @code{do_slot} -in the @C{} interface to @R{}. - [EMAIL PROTECTED] ->>> matrix = rinterface.globalEnv.get("matrix") ->>> letters = rinterface.globalEnv.get("letters") ->>> ncol = rinterface.SexpVector([2, ], rinterface.INTSXP) ->>> m = matrix(letters, ncol = ncol) ->>> [x for x in m.do_slot("dim")] -[13, 2] [EMAIL PROTECTED] example - - - [EMAIL PROTECTED] SexpVector [EMAIL PROTECTED] SexpVector - [EMAIL PROTECTED] Overview -In @R{} all scalars are in fact vectors. -Anything like a one-value variable is a vector of -length 1. - -To use again the constant @code{pi}: [EMAIL PROTECTED] ->>> pi = rinterface.globalEnv.get("pi") ->>> len(pi) -1 ->>> pi -<rinterface.SexpVector - Python:0x2b20325d2660 / R:0x16d5248> ->>> pi[0] -3.1415926535897931 [EMAIL PROTECTED] example - -Important note: The @code{__getitem__} operator @code{[} -is returning a @Python{} scalar. Because of that casting -an @code{SexpVector} into a list is only a matter of calling -the constructor @code{list}. - -The letters of the (western) alphabet are: [EMAIL PROTECTED] ->>> letters = rinterface.globalEnv.get("letters") ->>> len(letters) -26 ->>> LETTERS = rinterface.globalEnv.get("LETTERS") [EMAIL PROTECTED] example - [EMAIL PROTECTED] Names -In @R{}, vectors can be named, that is each value in the vector -can be given a name (that is be associated a string). -The names are added to the other as an attribute (conveniently -called names), and can be accessed as such: [EMAIL PROTECTED] ->>> options = rinterface.globalEnv.get("options")() ->>> option_names = options.do_slot("names") ->>> [x for x in options_names] [EMAIL PROTECTED] example -(to know more about @code{do_slot}, @xref{do_slot}). - [EMAIL PROTECTED] Numeric, numarray, numpy (and future possible names) - -The SexpVector objects are made to behave like arrays as defined -in the @Python{} packages Numeric, numarray, and numpy. - -The functions @code{array} and @code{asarray} is all that is needed: [EMAIL PROTECTED] ->>> import Numeric ->>> rx = rinterface.SexpVector([1,2,3,4], rinterface.INTSXP) ->>> nx = Numeric.array(rx) ->>> nx_nc = Numeric.asarray(rx) [EMAIL PROTECTED] example - -Important note: when using @code{asarray}, the data are not copied. [EMAIL PROTECTED] ->>> nx_nc[2] = 42 ->>> rx[2] -42 [EMAIL PROTECTED] example - - [EMAIL PROTECTED] SexpEnvironment [EMAIL PROTECTED] SexpEnvironment - [EMAIL PROTECTED] get -Whenever a search for a symbol is performed, the whole -search path is considered: the environments in the list -are inspected in sequence and the value for the first symbol found -matching is returned. - [EMAIL PROTECTED] ->>> rinterface.globalEnv.get("pi") [EMAIL PROTECTED] example - -The constant pi is defined in the package base, that -is by default in the search path. - - [EMAIL PROTECTED] __getitem__ / __setitem__ - -The @code{[} operator will only look for a symbol in the environment -(FIXME: first in the list then ?), -without looking into other elements in the list. - -The following will return an expection @code{LookupError}: [EMAIL PROTECTED] ->>> rinterface.globalEnv["pi"] [EMAIL PROTECTED] example -The constant @code{pi} is defined in @R{}'s @code{base} package, -and therefore cannot be found in the Global Environment. - -The assignment of a value to a symbol in an environment is as -simple as assigning a value to a key in a @Python{} dictionary: [EMAIL PROTECTED] ->>> x = rinterface.Sexp_Vector([123, ], rinterface.INTSXP) ->>> rinterface.globalEnv["x"] = x [EMAIL PROTECTED] example -note: a copy of the @R{} object is made in the @R{} space. - [EMAIL PROTECTED] __iter__ - -The object is made iter-able. - -For example, we take the base name space (that is the environment -that contains @R{}'s base objects: [EMAIL PROTECTED] ->>> base = rinterface.baseNameSpace ->>> basetypes = [x.typeof() for x in base] [EMAIL PROTECTED] example - -Note that in the current implementation the content of the environment -is evaluated only once, when the iterator is created, and that adding -or removing elements to the environment after will not have any effect. - [EMAIL PROTECTED] SexpClosure [EMAIL PROTECTED] SexpClosure - [EMAIL PROTECTED] A function with a context -In @R{} terminology, a closure is a function (with its enclosing -environment). That enclosing environment can be thought of as -a context to the function. - [EMAIL PROTECTED] ->>> sum = rinterface.globalEnv.get("sum") ->>> x = rinterface.SexpVector([1,2,3], rinterface.INTSXP) ->>> s = sum(x) ->>> s[0] -6 [EMAIL PROTECTED] example - [EMAIL PROTECTED] closureEnv - -In the example below, we inspect the environment for the -function @code{plot}, that is the namespace for the -package @code{graphics}. [EMAIL PROTECTED] ->>> plot = rinterface.globalEnv.get("plot") ->>> ls = rinterface.globalEnv.get("ls") ->>> envplot_list = ls(plot.closureEnv()) ->>> [x for x in envplot_ls] [EMAIL PROTECTED] example - - [EMAIL PROTECTED] Acknowledgements, , , Top [EMAIL PROTECTED] Acknowledgements - -This is an attempt at rewritting and extending -the @RPy{} project. Acknowledgements go to: -(FIXME: names are probably forgotten) - [EMAIL PROTECTED] @asis - [EMAIL PROTECTED] Walter Moreira -for the orignal implementation of @RPy{}. - [EMAIL PROTECTED] Gregory Warnes -for maintaining @RPy{} across the years, bringing it -a version 1.0, and fixing it to accomodate changes in R. - [EMAIL PROTECTED] Alexander Belopolsky -for his very nice contributed code to RPy (that code was a cornerstone -in rewriting RPy). [EMAIL PROTECTED] table - [EMAIL PROTECTED] Modified: branches/rpy_nextgen/doc/source/conf.py =================================================================== --- branches/rpy_nextgen/doc/source/conf.py 2008-06-01 12:04:10 UTC (rev 542) +++ branches/rpy_nextgen/doc/source/conf.py 2008-06-01 13:12:40 UTC (rev 543) @@ -23,7 +23,7 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -#extensions = [] +extensions = ['doctest', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] Modified: branches/rpy_nextgen/doc/source/overview.rst =================================================================== --- branches/rpy_nextgen/doc/source/overview.rst 2008-06-01 12:04:10 UTC (rev 542) +++ branches/rpy_nextgen/doc/source/overview.rst 2008-06-01 13:12:40 UTC (rev 543) @@ -1,41 +1,60 @@ Overview ======== +Background +---------- + `Python`_ is a popular -all-purpose scripting language, while `R`_ +all-purpose scripting language, while `R`_ (an open source implementation +of the S/Splus language) is a scripting language mostly popular for data analysis, statistics, and -graphics. +graphics. If you are reading this, there are good chances that you are +at least familiar with one of the two. .. _Python: http://www.python.org .. _R: http://www.r-project.org -The RPy project is an effort to have access to R from within Python, +Having an interface between both languages, and benefit from the respective +libraries of one language while working in the other language, appeared +desirable and an early option to achieve it was the RSPython project, +itself part of the `Omegahat project`_. -The RPy code was initially inspired in RSPython, which is part of -the `Omegahat project`_. +A bit later, the RPy project appeared and focused on providing simple and +robust access to R from within Python, with the initial Unix-only releases +quickly followed by Microsoft and MacOS compatible versions. +This project is referred to as RPy-1.x in the +rest of this document. .. _Omegahat project: http://www.omegahat.org/RSPython -RPy2 is inspired by RPy, as well as A. Belopolskys's contributions to RPy. -A compatibility layer with RPy is provided. +The present documentation covers RPy2, an evolution of RPy-1.x. +Naturally RPy2 is inspired by RPy, but also by A. Belopolskys's contributions +that were waiting to be included into RPy. -FIXME: write a section about what changed +Contents +-------- +The package is made of several sub-packages or modules: +:mod:`rpy2.rpy_classic` +^^^^^^^^^^^^^^^^^^^^^^^ -The package is made of several elements: +Higher-level interface similar to the one in RPy-1.x. +This is provided for compatibility reasons, and facilitate the migration +to RPy2. -:mod:`rpy_classic` - Higher-level interface similar to the one in RPy-1.x +:mod:`rpy2.robjects` +^^^^^^^^^^^^^^^^^^^^ -:mod:`robjects` - Higher-level interface, when ease-of-use matters most +Higher-level interface, when ease-of-use matters most. -:mod:`rinterface` - Low-level interface to R, when speed and flexibility - matter most. Here the programmer gets close to R's C - API, and can use R's function faster than within an R session. +:mod:`rpy2.rinterface` +^^^^^^^^^^^^^^^^^^^^^^ +Low-level interface to R, when speed and flexibility +matter most. Here the programmer gets close(r) to R's C +API. + Modified: branches/rpy_nextgen/doc/source/rinterface.rst =================================================================== --- branches/rpy_nextgen/doc/source/rinterface.rst 2008-06-01 12:04:10 UTC (rev 542) +++ branches/rpy_nextgen/doc/source/rinterface.rst 2008-06-01 13:12:40 UTC (rev 543) @@ -1,10 +1,14 @@ .. index:: - module: rinterface + module: rpy2.rinterface ********** rinterface ********** +.. module:: rpy2.rinterface + :synopsis: Low-level interface with R + + Overview ======== @@ -19,6 +23,7 @@ .. index:: single: initEmbeddedR + single: initialize :func:`initEmbeddedR` --------------------- @@ -46,6 +51,7 @@ .. index:: single: globalEnv + single: SexpEnvironment; globalEnv globalEnv --------- @@ -63,6 +69,7 @@ .. index:: single: baseNamespaceEnv + single: SexpEnvironment; baseNamespaceEnv baseNamespaceEnv ---------------- @@ -90,6 +97,9 @@ do_slot([name]) Access attribute *name* for the object +.. index:: + single: Sexp; typeof + :meth:`typeof` -------------- @@ -100,6 +110,8 @@ FIXME: talk about the all the types. +.. index:: + single: Sexp; do_slot :meth:`do_slot` --------------- @@ -141,10 +153,11 @@ 3.1415926535897931 >>> -Important note: The *__getitem__* operator *[* -is returning a Python scalar. Because of that casting -an *SexpVector* into a list is only a matter of calling -the constructor *list*. +.. note:: + The *__getitem__* operator *[* + is returning a Python scalar. Because of that casting + an *SexpVector* into a list is only a matter of calling + the constructor *list*. The letters of the (western) alphabet are: @@ -284,41 +297,59 @@ .. index:: single: R_LEN_T_MAX + single: R_HOME + single: TRUE + single: FALSE R_HOME R HOME -R_LEN_T_MAX +:const:`R_LEN_T_MAX` largest usable integer for indexing R vectors -TRUE/FALSE +:const:`TRUE`/:const:`FALSE` R's TRUE and FALSE -NA_INTEGER - NA value for integers +:const:`NA_INTEGER` + Missing value for integers -NA_LOGICAL - NA value for booleans +:const:`NA_LOGICAL` + Missing value for booleans -NA_REAL - NA value for numerical values (float / double) +:const:`NA_REAL` + Missing value for numerical values (float / double) -INTSXP +.. index:: + single: ENVSXP + single: type; ENVSXP + single: INTSXP + single: type; INTSXP + single: LGLSXP + single: type; LGLSXP + single: STRSXP + single: type; STRSXP + single: REALSXP + single: type; REALSXP + +R types +------- + +:const:`INTSXP` Integer -REALSXP +:const:`REALSXP` Numerical value (float / double) -LGLSXP +:const:`LGLSXP` Boolean (logical in the R terminology) -STRSXP +:const:`STRSXP` String -ENVSXP +:const:`ENVSXP` Environment -CPLXSXP +:const:`CPLXSXP` Complex Modified: branches/rpy_nextgen/doc/source/robjects.rst =================================================================== --- branches/rpy_nextgen/doc/source/robjects.rst 2008-06-01 12:04:10 UTC (rev 542) +++ branches/rpy_nextgen/doc/source/robjects.rst 2008-06-01 13:12:40 UTC (rev 543) @@ -1,3 +1,7 @@ +.. index:: + module: rpy2.robjects + + ************* rpy2.robjects ************* @@ -2,2 +6,6 @@ +.. module:: rpy2.robjects + :synopsis: High-level interface with R + + Overview @@ -105,8 +113,6 @@ ltr_np = numpy.array(ltr) - - :class:`Renvironment` --------------------- @@ -196,6 +202,8 @@ Principal component analysis ---------------------------- +The R code is + .. code-block:: r m <- matrix(rnorm(100), ncol=5) @@ -203,6 +211,8 @@ plot(pca, main="Eigen values") biplot(pca, main="biplot") +The :mod:`rpy2.robjects` code is + .. code-block:: python m = r.matrix(r.rnorm(100), ncol=5) Modified: branches/rpy_nextgen/doc/source/rpy_classic.rst =================================================================== --- branches/rpy_nextgen/doc/source/rpy_classic.rst 2008-06-01 12:04:10 UTC (rev 542) +++ branches/rpy_nextgen/doc/source/rpy_classic.rst 2008-06-01 13:12:40 UTC (rev 543) @@ -1,3 +1,7 @@ +.. index:: + module: rpy2.rpy_classic + + *********** rpy_classic *********** @@ -2,17 +6,32 @@ -The module aims at providing an API similar to -the one in RPy-1.x. +.. module:: rpy2.rpy_classic + :synopsis: Provide compatibility with rpy -Loading the module can be done as: +This module provides an API similar to the one +in RPy-1.x (*rpy*). +To match examples and documentation for *rpy*, +we load the module as: + >>> from rpy2.rpy_classic import * +.. index:: + single: conversion -The conversion system is still around: +Conversion +---------- +Although the proposed high-level interface in :mod:`rpy2.robjects` +does not need explicit conversion settings, the conversion system +existing in *rpy* is provided, and the default +mode can be set with :func:`set_default_mode`: + >>> set_default_mode(NO_CONVERSION) >>> set_default_mode(BASIC_CONVERSION) -The ``r`` instance behaves like before: +R instance +---------- +The ``r`` instance of class :class:`R` behaves like before: + >>> r.help @@ -51,14 +70,18 @@ True >>> +If an object is not a R function, a :class:`RuntimeError` +is thrown by R whenever called: + +>>> r.pi() + +The function are called like regular Python functions: + >>> r.seq(1, 3) >>> r.seq(1, 3, by=0.5) >>> r['options'](show_coef_Pvalues=0) -Whenever object is not a function, a runtime error -is thrown by R. ->>> r.pi() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list