There are several times in R when it is valuable to explicitly leave
an argument missing. For example, when extracting a row from a matrix:

> m <- matrix(1:4, nrow=2)
> m[2]   # Flat indexing
[1] 2
> m[2, ] # Note the comma!
[1] 2 4

However, there is currently no way to support this (rather
idiosyncratic) syntax in rpy2.

The attached patch adds a function rpy2.rinterface.getMissingArgSexp
which returns an Sexp wrapping the magic R_MissingArg object. With
this patch, the following becomes possible:

>>> m = r.matrix([1, 2, 3, 4], nrow=2)
>>> r["["](m, 2, rpy2.rinterface.getMissingArgSexp())

Patch includes tests, which pass for me.

-- Nathaniel

Attachment: NEW_getMissingArgSexp
Description: Binary data

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to