Revision: 544
          http://rpy.svn.sourceforge.net/rpy/?rev=544&view=rev
Author:   lgautier
Date:     2008-06-01 08:07:21 -0700 (Sun, 01 Jun 2008)

Log Message:
-----------
Some more documentation.

Modified Paths:
--------------
    branches/rpy_nextgen/doc/source/rinterface.rst
    branches/rpy_nextgen/doc/source/robjects.rst

Modified: branches/rpy_nextgen/doc/source/rinterface.rst
===================================================================
--- branches/rpy_nextgen/doc/source/rinterface.rst      2008-06-01 13:12:40 UTC 
(rev 543)
+++ branches/rpy_nextgen/doc/source/rinterface.rst      2008-06-01 15:07:21 UTC 
(rev 544)
@@ -179,22 +179,25 @@
 >>> [x for x in options_names]
 
 
+.. index::
+   single: numpy
 
-Numeric, numarray, numpy (and future possible names)
-----------------------------------------------------
+Numpy
+-----
 
 The SexpVector objects are made to behave like arrays as defined
-in the Python packages Numeric, numarray, and numpy.
+in the Python package numpy.
 
 The functions *array* and *asarray* is all that is needed:
 
->>> import Numeric
+>>> import numpy
 >>> rx = rinterface.SexpVector([1,2,3,4], rinterface.INTSXP)
->>> nx = Numeric.array(rx)
->>> nx_nc = Numeric.asarray(rx)
+>>> nx = numpy.array(rx)
+>>> nx_nc = numpy.asarray(rx)
 
 
-Important note: when using *asarray*, the data are not copied.
+.. note::
+   when using *asarray*, the data are not copied.
 
 >>> nx_nc[2] = 42
 >>> rx[2]

Modified: branches/rpy_nextgen/doc/source/robjects.rst
===================================================================
--- branches/rpy_nextgen/doc/source/robjects.rst        2008-06-01 13:12:40 UTC 
(rev 543)
+++ branches/rpy_nextgen/doc/source/robjects.rst        2008-06-01 15:07:21 UTC 
(rev 544)
@@ -21,12 +21,12 @@
 >>> import rpy2.robjects as robjects
 
 
-:mod:`robjects` is written on the top of :mod:`rinterface`, and one
+:mod:`rpy2.robjects` is written on the top of :mod:`rpy2.rinterface`, and one
 not satisfied with it could easily build one's own flavor of a
-Python-R interface by modifying it.
+Python-R interface by modifying it (:mod:`rpy2.rpy_classic` is an other
+example of a Python interface built on the top :mod:`rpy2.rinterface`).
 
-Classes
-=======
+Classes:
 
 :class:`Robject`
   Parent class for R objects.
@@ -41,8 +41,8 @@
   An R function.
 
 
-R
--
+Class R
+=======
 
 This class is currently a singleton, with
 its one representation instanciated when the
@@ -51,9 +51,12 @@
 >>> robjects.r
 >>> print(robjects.r)
 
-The instance can be seen as a window to an
-embedded R process.
-Readers familiar with the ctypes module for Python
+The instance can be seen as the entry point to an
+embedded R process, and the elements that would be accessible
+from an equivalent R environment are accessible as attributes
+of the instance.
+Readers familiar with the ctypes module for Python will note
+the similarity with ctypes.
 
 R vectors:
 
@@ -66,15 +69,26 @@
 >>> plot = robjects.r.plot
 >>> dir = robjects.r.dir
 
-The evaluation of R code in a string can also be performed
-FIXME: (not yet implemented/tested)
+Just like it was the case with RPy-1.x, on-the-fly
+evaluation of R code contained in a string can be performed
+by calling the r instance:
 
-:class:`Robject`
-----------------
+>>> robjects.r('1:2')
+3
+>>> sqr = ro.r('function(x) x^2)
+>>> sqr
+function (x)
+x^2
+>>> sqr(2)
+4
 
-:class:`Rvector`
-----------------
 
+Class :class:`Robject`
+======================
+
+Class :class:`Rvector`
+======================
+
 Beside 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
@@ -99,13 +113,41 @@
 | ``/`` | Divide  |
 +-------+---------+
 
-FIXME:
+.. index::
+   single: indexing
+
 Indexing
+--------
 
-This class is using the class :class:`rinterface.SexpVector`.
+Indexing can become a thorny issue, since Python indexing starts at zero
+and R indexing starts at one.
 
-Numpy, Numeric
+The python :meth:`__getitem__` method behaves like a Python user would expect
+it for a vector (and indexing starts at zero),
+while the method :meth:`subset` behaves like a R user would expect it
+(indexing starts at one, and a vector of integers, booleans, or strings can
+be given to subset elements).
 
+>>> x = robjects.r.seq(1, 10)
+>>> x[0]
+1
+>>> x.subset(0)
+integer(0)
+>>> x.subset(1)
+1L
+>>> x.subset(-1)
+2:10
+>>> x.subset(True)
+1:10
+
+This class is using the class :class:`rinterface.SexpVector`, 
+and its documentation can be referred to for details of what is happenening
+at the low-level.
+
+
+Numpy
+-----
+
 Vectors are understood as Numpy or Numeric arrays::
 
   import numpy
@@ -113,8 +155,8 @@
   ltr_np = numpy.array(ltr)
 
 
-:class:`Renvironment`
----------------------
+Class :class:`REnvironment`
+===========================
 
 R environments can be described to the Python user as
 an hybrid of a dictionary and a scope.
@@ -160,8 +202,8 @@
 >>> len([x for x in env])
 
 
-:class:`Rfunction`
-------------------
+Class :class:`Rfunction`
+========================
 
 >>> plot = robjects.r.plot
 >>> rnorm = robjects.r.rnorm
@@ -170,8 +212,8 @@
 This class is using the class :class:`rinterface.SexpClosure`
 
 
-Mapping
--------
+Mapping between rpy2 objects and other python objects
+=====================================================
 
 The mapping between low-level objects is performed by the
 functions XXX and XXX.
@@ -219,11 +261,13 @@
   pca = r.princomp(m)
   r.plot(pca, main="Eigen values")
   r.biplot(pca, main="biplot")
+   
 
 
 S4 classes
 ----------
 
+
 .. code-block:: python
 
   if not r.require("GO")[0]:


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

Reply via email to