Revision: 569
http://rpy.svn.sourceforge.net/rpy/?rev=569&view=rev
Author: lgautier
Date: 2008-07-02 08:07:59 -0700 (Wed, 02 Jul 2008)
Log Message:
-----------
- Reflect changes in the code
- Added more doc
- Fixed doc
- getting ready for v.2.0a1
Modified Paths:
--------------
branches/rpy_nextgen/doc/source/conf.py
branches/rpy_nextgen/doc/source/index.rst
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
Added Paths:
-----------
branches/rpy_nextgen/doc/source/changes.rst
Added: branches/rpy_nextgen/doc/source/changes.rst
===================================================================
--- branches/rpy_nextgen/doc/source/changes.rst (rev 0)
+++ branches/rpy_nextgen/doc/source/changes.rst 2008-07-02 15:07:59 UTC (rev
569)
@@ -0,0 +1,8 @@
+:tocdepth: 2
+
+.. _changes:
+
+Changes in rpy2
+***************
+
+.. include:: ../../NEWS
Modified: branches/rpy_nextgen/doc/source/conf.py
===================================================================
--- branches/rpy_nextgen/doc/source/conf.py 2008-07-02 15:04:22 UTC (rev
568)
+++ branches/rpy_nextgen/doc/source/conf.py 2008-07-02 15:07:59 UTC (rev
569)
@@ -23,8 +23,9 @@
# Add any Sphinx extension module names here, as strings. They can be
extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['doctest', ]
+extensions = ['sphinx.ext.doctest', ]
+
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -42,9 +43,9 @@
# other places throughout the built documents.
#
# The short X.Y version.
-version = '1.0'
+version = '2.0'
# The full version, including alpha/beta/rc tags.
-release = '1.0a1'
+release = '2.0a1'
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
@@ -90,6 +91,10 @@
# the sidebar.
html_logo = 'rpy_logo_header.png'
+
+
+html_favicon = 'rpy.ico'
+
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
@@ -132,7 +137,7 @@
# ------------------------
# The paper size ('letter' or 'a4').
-#latex_paper_size = 'letter'
+latex_paper_size = 'a4'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
Modified: branches/rpy_nextgen/doc/source/index.rst
===================================================================
--- branches/rpy_nextgen/doc/source/index.rst 2008-07-02 15:04:22 UTC (rev
568)
+++ branches/rpy_nextgen/doc/source/index.rst 2008-07-02 15:07:59 UTC (rev
569)
@@ -2,8 +2,8 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
-Welcome to rpy2's documentation!
-================================
+Documentation for rpy2
+======================
Contents:
@@ -12,10 +12,13 @@
preface
overview
- rpy_classic
robjects
rinterface
+ rpy_classic
+ changes
+
+
Indices and tables
==================
Modified: branches/rpy_nextgen/doc/source/overview.rst
===================================================================
--- branches/rpy_nextgen/doc/source/overview.rst 2008-07-02 15:04:22 UTC
(rev 568)
+++ branches/rpy_nextgen/doc/source/overview.rst 2008-07-02 15:07:59 UTC
(rev 569)
@@ -31,6 +31,46 @@
Naturally RPy2 is inspired by RPy, but also by A. Belopolskys's contributions
that were waiting to be included into RPy.
+Installation
+------------
+
+Requirements
+^^^^^^^^^^^^
+
+Python version 2.4 or higher, and R-2.7.0 or higher are required.
+
+
+
+Download
+^^^^^^^^
+
+Source Python packages, as well as pre-compiled binaries for Microsoft's
Windows are available
+on the Sourceforge page.
+
+
+.. note::
+ MacOSX binaries may appear in the future (contributions to build them are
welcome)
+
+
+Microsoft's Windows precompiled binaries
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The executable can be ran; they will install the package in the default Python
installation
+on the system.
+
+
+Install from source
+^^^^^^^^^^^^^^^^^^^
+
+To install from a source package `<rpy_package>` do in a shell:
+
+.. code-block:: bash
+
+ tar -xzf <rpy_package>.tar.gz
+ cd <rpy_package>
+ python setup.py install
+
+
Contents
--------
Modified: branches/rpy_nextgen/doc/source/rinterface.rst
===================================================================
--- branches/rpy_nextgen/doc/source/rinterface.rst 2008-07-02 15:04:22 UTC
(rev 568)
+++ branches/rpy_nextgen/doc/source/rinterface.rst 2008-07-02 15:07:59 UTC
(rev 569)
@@ -1,18 +1,16 @@
-.. index::
- module: rpy2.rinterface
-
**********
rinterface
**********
.. module:: rpy2.rinterface
+ :platform: Unix, Windows
:synopsis: Low-level interface with R
Overview
========
-A lower-level interface is provided for cases where
+A lower-level interface is provided for situations where
the use-cases addressed by :mod:`robjects` are not covered,
and for the cases where the layer in :mod:`robjects`
has an excessive cost in term of performances.
@@ -46,9 +44,9 @@
.. note::
If calling :func:`initEmbeddedR` returns an error stating that
- `R_HOME` is not 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.
+ :envvar:`R_HOME` is not defined, you should either have the :program:`R`
executable in
+ your path (:envvar:`PATH` on unix-alikes, or :envvar:`Path` on Microsoft
Windows) or
+ have the environment variable :envvar:`R_HOME` defined.
R space and Python space
------------------------
@@ -94,6 +92,26 @@
.. index::
single: Sexp
+Ouput from the R console
+------------------------
+
+The function :meth:`setWriteConsole` let one specify what do with
+output from the R console with a callback function.
+
+An example should make it obvious::
+
+ buf = []
+ def f(x):
+ # function that append its argument to the list 'buf'
+ buf.append(x)
+
+ # output from the R console will now be appended to the list 'buf'
+ rinterface.setWriteConsole(f)
+
+
+
+
+
:class:`Sexp`
=============
@@ -257,6 +275,7 @@
:class:`SexpEnvironment`
========================
+
:meth:`get`
-----------
@@ -270,9 +289,7 @@
The constant pi is defined in the package base, that
is by default in the search path.
-FIXME: get functions only
-
:meth:`__getitem__` / :meth:`__setitem__`
-----------------------------------------
@@ -293,8 +310,14 @@
>>> x = rinterface.Sexp_Vector([123, ], rinterface.INTSXP)
>>> rinterface.globalEnv["x"] = x
-note: a copy of the R object is made in the R space.
+.. note::
+ Not all R environment are hash tables, and this may
+ influence performances when doing repeated lookups
+
+.. note::
+ a copy of the R object is made in the R space.
+
:meth:`__iter__`
----------------
@@ -307,10 +330,13 @@
>>> basetypes = [x.typeof() for x in base]
-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.
+.. warning::
+ In the current implementation the content of the environment
+ is evaluated only once, when the iterator is created. Adding
+ or removing elements to the environment will not update the iterator
+ (this is a problem, that will be solved in the near future).
+
.. index::
single: closure
single: SexpClosure
Modified: branches/rpy_nextgen/doc/source/robjects.rst
===================================================================
--- branches/rpy_nextgen/doc/source/robjects.rst 2008-07-02 15:04:22 UTC
(rev 568)
+++ branches/rpy_nextgen/doc/source/robjects.rst 2008-07-02 15:07:59 UTC
(rev 569)
@@ -1,14 +1,14 @@
-. index::
- module: rpy2.robjects
-
*************
rpy2.robjects
*************
.. module:: rpy2.robjects
+ :platform: Unix, Windows
:synopsis: High-level interface with R
+.. testsetup:: robjects
+ import rpy2.robjects as robjects
Overview
========
@@ -30,6 +30,7 @@
- no CONVERSION mode in :mod:`rpy2`, the design has made this unnecessary
+- easy to modify or rewrite with an all-Python implementation
@@ -40,6 +41,7 @@
its one representation instanciated when the
module is loaded:
+
>>> robjects.r
>>> print(robjects.r)
@@ -84,7 +86,7 @@
be plugged into code by their string representation:
>>> x = robjects.r.rnorm(100)
->>> robjects.r('hist(%s, xlab="x", main="hist(x)")' %x.__repr__())
+>>> robjects.r('hist(%s, xlab="x", main="hist(x)")' %repr(x))
@@ -120,29 +122,7 @@
The class inherits from the class
:class:`rpy2.rinterface.VectorSexp`.
-Operators
----------
-Mathematical operations on two vectors: the following operations
-are performed element-wise, recycling the shortest vector if, and
-as much as, necessary.
-
-+--------+---------+
-| ``+`` | Add |
-+--------+---------+
-| ``-`` | Subtract|
-+--------+---------+
-| ``*`` | Multiply|
-+--------+---------+
-| ``/`` | Divide |
-+--------+---------+
-| ``**`` | Power |
-+--------+---------+
-| ``or`` | Or |
-+--------+---------+
-| ``and``| And |
-+--------+---------+
-
.. index::
pair: RVector;indexing
@@ -166,18 +146,59 @@
>>> x.subset(1)
1L
+Rather than calling :meth:`subset`, and to still have the conveniently
+short `[` operator available, a syntactic sugar is available in
+the form of delegating-like attribute :attr:`r`.
+
+>>> x.r[0]
+integer(0)
+>>> x.r[1]
+1L
+
The two next examples demonstrate features of `R` regarding indexing,
respectively element exclusion and recycling rule:
->>> x.subset(-1)
+
+>>> x.r[-1]
2:10
->>> x.subset(True)
+>>> x.r[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.
+Operators
+---------
+Mathematical operations on two vectors: the following operations
+are performed element-wise in R, recycling the shortest vector if, and
+as much as, necessary.
+
+The delegating attribute mention in the Indexing section can also
+be used with the following operators:
+
++----------+---------+
+| operator | R (.r) |
++----------+---------+
+| ``+`` | Add |
++----------+---------+
+| ``-`` | Subtract|
++----------+---------+
+| ``*`` | Multiply|
++----------+---------+
+| ``/`` | Divide |
++----------+---------+
+| ``**`` | Power |
++----------+---------+
+| ``or`` | Or |
++----------+---------+
+| ``and`` | And |
++----------+---------+
+
+>>> x = robjects.r.seq(1, 10)
+>>> x.r + 1
+2:11
+
.. index::
pair: RVector; numpy
@@ -323,15 +344,32 @@
.. code-block:: python
- fit = robjects.r('lm(%s)' %fmla.__repr__())
+ fit = robjects.r('lm(%s)' %repr(fmla))
Mapping between rpy2 objects and other python objects
=====================================================
-The mapping between low-level objects is performed on
-the fly by functions XXX
+The conversion, as often needed with RPy-1.x, is no longer
+necessary as the R objects can be either passed on to R functions
+or used in Python. T
+There is a low-level mapping between `R` and `Python` objects
+performed behind the (Python-level) scene.
+
+The mapping between low-level objects and higher-level objects
+is performed by the functions.
+
+:meth:`ri2py`
+ :mod:`rpy2.rinterface` to Python
+
+:meth:`py2ri`
+ Python to :mod:`rpy2.rinterface`
+
+:meth:`py2ro`
+ Python to :mod:`rpy2.robjects`. That one function
+ is merely a call to py2ri followed by a call to ri2py.
+
Those functions can be modifyied to satisfy all requirements.
@@ -343,8 +381,8 @@
will hopefully be used as a cookbook.
-Example::
-
+.. testcode:: robjects
+ import rpy2.robjects as robjects
import array
r = robjects.r
@@ -380,6 +418,11 @@
.. code-block:: python
+ import rpy2.robjects as robjects
+ import array
+
+ r = robjects.r
+
ctl = array.array('f', [4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14])
trt = array.array('f', [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"])
@@ -409,8 +452,12 @@
The :mod:`rpy2.robjects` code is
-.. code-block:: python
+.. testcode::
+ import rpy2.robjects as robjects
+
+ r = robjects.r
+
m = r.matrix(r.rnorm(100), ncol=5)
pca = r.princomp(m)
r.plot(pca, main="Eigen values")
@@ -421,11 +468,16 @@
S4 classes
----------
-
.. code-block:: python
- if not r.require("GO")[0]:
- raise(Exception("Bioconductor Package GO missing"))
+ import rpy2.robjects as robjects
+ import array
- goItem = r.GOTERM["GO:0000001"]
+ r = robjects.r
+ r.setClass("Track",
+ r.representation(x="numeric", y="numeric"))
+
+ a = r.new("Track", x=0, y=1)
+
+ a.x
\ No newline at end of file
Modified: branches/rpy_nextgen/doc/source/rpy_classic.rst
===================================================================
--- branches/rpy_nextgen/doc/source/rpy_classic.rst 2008-07-02 15:04:22 UTC
(rev 568)
+++ branches/rpy_nextgen/doc/source/rpy_classic.rst 2008-07-02 15:07:59 UTC
(rev 569)
@@ -1,14 +1,10 @@
-.. index::
- module: rpy2.rpy_classic
-
***********
rpy_classic
***********
-.. module:: rpy2.rpy_classic
- :synopsis: Provide compatibility with rpy
+
This module provides an API similar to the one
in RPy-1.x (*rpy*).
@@ -22,7 +18,7 @@
single: rpy_classic; conversion
Conversion
-----------
+==========
Although the proposed high-level interface in :mod:`rpy2.robjects`
does not need explicit conversion settings, the conversion system
@@ -33,7 +29,7 @@
>>> set_default_mode(BASIC_CONVERSION)
R instance
-----------
+==========
The ``r`` instance of class :class:`R` behaves like before:
@@ -61,10 +57,10 @@
type(r.seq)
.. index::
- pair: rpy_classic; function
+ pair: rpy_classic;function
Functions
----------
+=========
As in RPy-1.x, all R objects are callable:
@@ -84,13 +80,13 @@
>>> r.seq(1, 3)
>>> r.seq(1, 3, by=0.5)
>>> r['options'](show_coef_Pvalues=0)
+>>>
-
>>> m = r.matrix(r.rnorm(100), 20, 5)
>>> pca = r.princomp(m)
>>> r.plot(pca, main = "PCA")
-
+>>>
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
rpy-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rpy-list