Revision: 550
http://rpy.svn.sourceforge.net/rpy/?rev=550&view=rev
Author: lgautier
Date: 2008-06-07 01:11:56 -0700 (Sat, 07 Jun 2008)
Log Message:
-----------
doc:
- added directory for build
- store logo in html/_static
- fixed doc to reflect recent changes in the code base
- added indexing
Modified Paths:
--------------
branches/rpy_nextgen/doc/source/rinterface.rst
branches/rpy_nextgen/doc/source/robjects.rst
branches/rpy_nextgen/doc/source/rpy_classic.rst
Added Paths:
-----------
branches/rpy_nextgen/doc/build/html/
branches/rpy_nextgen/doc/build/html/_sources/
branches/rpy_nextgen/doc/build/html/_static/
branches/rpy_nextgen/doc/build/html/_static/rpy_logo_header.png
Added: branches/rpy_nextgen/doc/build/html/_static/rpy_logo_header.png
===================================================================
(Binary files differ)
Property changes on:
branches/rpy_nextgen/doc/build/html/_static/rpy_logo_header.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Modified: branches/rpy_nextgen/doc/source/rinterface.rst
===================================================================
--- branches/rpy_nextgen/doc/source/rinterface.rst 2008-06-07 07:05:47 UTC
(rev 549)
+++ branches/rpy_nextgen/doc/source/rinterface.rst 2008-06-07 08:11:56 UTC
(rev 550)
@@ -39,8 +39,17 @@
when using the embedded R, an exception is be fired.
Parameters for the initialization are in the module variable
-initOptions.
+`initOptions`.
+.. index::
+ single: initialize R_HOME
+
+.. note::
+ If calling :func:`initEmbeddedR` returns an error stating that
+ `R_HOME` is defined, you should either have the R executable in
+ your path ($PATH on unix-alikes, %Path% on Microsoft Windows) or
+ have the environment variable `R_HOME` defined.
+
R space and Python space
------------------------
@@ -68,7 +77,7 @@
The library is said to be attached to the current search path.
.. index::
- single: baseNamespaceEnv
+ pair: rinterface; baseNamespaceEnv
single: SexpEnvironment; baseNamespaceEnv
baseNamespaceEnv
@@ -153,12 +162,6 @@
3.1415926535897931
>>>
-.. 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:
>>> letters = rinterface.globalEnv.get("letters")
@@ -166,6 +169,25 @@
26
>>> LETTERS = rinterface.globalEnv.get("LETTERS")
+
+.. index::
+ pair: rinterface;indexing
+
+Indexing
+--------
+
+The indexing is working like it would on regular `Python`
+tuples or lists.
+The indexing starts at 0 (zero), which differs from `R`,
+where indexing start at 1 (one).
+
+.. note::
+ The *__getitem__* operator *[*
+ is returning a Python scalar. Casting
+ an *SexpVector* into a list is only a matter of calling
+ the constructor *list*.
+
+
Names
-----
@@ -264,6 +286,10 @@
is evaluated only once, when the iterator is created, and that adding
or removing elements to the environment after will not have any effect.
+.. index::
+ single: closure
+ pair: rinterface; function
+
:class:`SexpClosure`
====================
@@ -314,6 +340,12 @@
:const:`TRUE`/:const:`FALSE`
R's TRUE and FALSE
+.. index::
+ single: missing values
+
+Missing values
+--------------
+
:const:`NA_INTEGER`
Missing value for integers
Modified: branches/rpy_nextgen/doc/source/robjects.rst
===================================================================
--- branches/rpy_nextgen/doc/source/robjects.rst 2008-06-07 07:05:47 UTC
(rev 549)
+++ branches/rpy_nextgen/doc/source/robjects.rst 2008-06-07 08:11:56 UTC
(rev 550)
@@ -24,20 +24,20 @@
: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 (:mod:`rpy2.rpy_classic` is an other
-example of a Python interface built on the top :mod:`rpy2.rinterface`).
+example of a Python interface built on the top of :mod:`rpy2.rinterface`).
Classes:
-:class:`Robject`
+:class:`RObject`
Parent class for R objects.
-:class:`Rvector`
+:class:`RVector`
An R vector
-:class:`Renvironment`
+:class:`REnvironment`
An R environment.
-:class:`Rfunction`
+:class:`RFunction`
An R function.
@@ -82,23 +82,41 @@
>>> sqr(2)
4
+.. index::
+ pair: robjects;RObject
-Class :class:`Robject`
-======================
+R objects
+=========
-Class :class:`Rvector`
-======================
+The class :class:`rpy2.robjects.RObject`
+represents an arbitray R object, meaning than object
+cannot be represented by any of the classes :class:`RVector`,
+:class:`RFunction`, :class:`REnvironment`.
+The class inherits from the class
+:class:`rpy2.rinterface.Sexp`.
+
+.. index::
+ pair: robjects;RVector
+
+R vectors
+=========
+
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
of length one.
-The class :class:`Rvector` has a constructor:
+The class :class:`RVector` has a constructor:
->>> x = robjects.Rvector(3)
+>>> x = robjects.RVector(3)
+The class inherits from the class
+:class:`rpy2.rinterface.VectorSexp`.
+Operators
+---------
+
Mathematical operations on vectors: the following operations
are performed element-wise, recycling the shortest vector if
necessary.
@@ -114,7 +132,7 @@
+-------+---------+
.. index::
- single: indexing
+ pair: RVector;indexing
Indexing
--------
@@ -154,9 +172,12 @@
ltr = robjects.r.letters
ltr_np = numpy.array(ltr)
+.. index::
+ pair: robjects;REnvironment
+ pair: robjects;globalEnv
-Class :class:`REnvironment`
-===========================
+R environments
+==============
R environments can be described to the Python user as
an hybrid of a dictionary and a scope.
@@ -193,25 +214,32 @@
>>> robjects.r.pi
3.1415926535897931
-This class is using the class :class:`rinterface.SexpEnvironment`
+The class inherits from the class
+:class:`rpy2.rinterface.SexpEnvironment`.
+
An environment is also iter-able, returning all the symbols
(keys) it contains:
>>> env = robjects.r.baseenv()
>>> len([x for x in env])
+.. index::
+ pair: robjects; RFunction
+ pair: robjects; function
-Class :class:`Rfunction`
-========================
+R functions
+===========
>>> plot = robjects.r.plot
>>> rnorm = robjects.r.rnorm
>>> plot(rnorm(100), ylab="random")
-This class is using the class :class:`rinterface.SexpClosure`
+The class inherits from the class
+:class:`rpy2.rinterface.SexpClosure`.
+
Mapping between rpy2 objects and other python objects
=====================================================
@@ -224,6 +252,11 @@
Examples
========
+The following section demonstrates some of the features of
+rpy2 by the example. The wiki on the sourceforge website
+will hopefully be used as a cookbook.
+
+
Example::
import array
@@ -241,6 +274,40 @@
kwargs = {'ylab':"foo/bar", 'type':"b", 'col':"blue", 'log':"x"}
r.plot(x, y, **kwargs)
+Linear models
+-------------
+
+The R code is:
+
+.. code-block:: r
+
+ ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
+ trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
+ group <- gl(2, 10, 20, labels = c("Ctl","Trt"))
+ weight <- c(ctl, trt)
+
+ anova(lm.D9 <- lm(weight ~ group))
+
+ summary(lm.D90 <- lm(weight ~ group - 1))# omitting intercept
+
+The :mod:`rpy2.robjects` code is
+
+.. code-block:: python
+
+ ctl = [4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14]
+ trt = [4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69]
+ group = r.gl(2, 10, 20, labels = ["Ctl","Trt"])
+ weight = ctl + trt
+
+ robjects.globalEnv["weight"] = weight
+ robjects.globalEnv["group"] = group
+ lm_D9 = r.lm("weight ~ group")
+ r.anova(lm_D9)
+
+ lm.D90 = r.lm("weight ~ group - 1"))
+ summary(lm.D90)
+
+
Principal component analysis
----------------------------
Modified: branches/rpy_nextgen/doc/source/rpy_classic.rst
===================================================================
--- branches/rpy_nextgen/doc/source/rpy_classic.rst 2008-06-07 07:05:47 UTC
(rev 549)
+++ branches/rpy_nextgen/doc/source/rpy_classic.rst 2008-06-07 08:11:56 UTC
(rev 550)
@@ -19,6 +19,7 @@
.. index::
single: conversion
+ single: rpy_classic; conversion
Conversion
----------
@@ -59,6 +60,9 @@
type(r.seq)
+.. index::
+ pair: rpy_classic; function
+
Functions
---------
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
rpy-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rpy-list