Hi list!
Normally in rpy2 I can do the following (or something similar):
>>> Line_ = robjects.r["Line"]
>>> Line_
<RFunction - Python:0xa11688c / R:0x9c841a8>
to get a function or variable from the global environment. Note: Line is
part of the sp (spatial objects) R package. However, if I've
(accidentally) created a variable named 'Line', when using the above
method to retrieve the function it retrieves the variable instead:
>>> robjects.r('Line <- "test"')
<RVector - Python:0xa116a0c / R:0xa49efa8>
>>> Line_ = robs.r['Line']
>>> Line_
<RVector - Python:0xa116a8c / R:0xa49efa8>
Ok, that's expected..., so instead I try:
>>> Line_ = rint.globalEnv.get("Line", wantFun=True)
>>> Line_
<rinterface.SexpClosure - Python:0xb7d383a0 / R:0x9c841a8>
now my problem is that I can no longer do something like (for example):
Line_(matrix_(unlist_([point for point in line]), nrow = X, byrow=True))
because I get a ValueError: All parameters must be of type Sexp_Type.
So my question is the following: Is it possible to get a function from
the global (or a package) environment similar to the initial example,
without having it blocked by variable names? Or similarly, is it
possible to get a function using the second example, except separate
from it's enclosing environment (i.e. SexpClosure)?
Maybe this is a stupid question and I should be going about this in an
entirely different way, and if that's the case, please let me know?!
Regards,
Carson
--
Carson J. Q. Farmer
ISSP Doctoral Fellow
National Centre for Geocomputation (NCG),
National University of Ireland, Maynooth,
Email: [email protected]
Web: http://www.carsonfarmer.com/
http://www.ftools.ca/
------------------------------------------------------------------------------
_______________________________________________
rpy-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rpy-list