Description Usage Arguments Details Value Examples
Calls Python functions and methods from R
1 2 | python.call( py.foo, ..., simplify = TRUE, as.is = FALSE )
python.method.call( py.object, py.method, ... )
|
py.foo |
rame of a Python function |
py.object |
name of a Python object |
py.method |
name of a method of such object |
... |
R objects to pass as arguments to the Python function or method |
simplify |
logical value indicating whether simplification of output should be simplified |
as.is |
logical value indicating whether length 1 vectors in R should be passed as atomic variables in Python as opposed to length 1 vectors. Note that, e.g., strings such as "hello" in R are vectors of length 1 in R, i.e., This argument provides little granularity: it affects either all or none of the arguments of the function. Finer control can be obtained using the |
This function runs a Python function taking as arguments R objects and returning an R object. Some limitations exist as to the nature of the objects that can be passed between R and Python. As of this writing, atomic arguments and vectors are supported.
The user has to be careful to indicate named parameters as required according to Python conventions.
An R representation of the object returned by the call to the Python function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | python.call( "len", 1:3 )
a <- 1:4
b <- 5:8
python.exec( "def concat(a,b): return a+b" )
python.call( "concat", a, b)
python.assign( "a", "hola hola" )
python.method.call( "a", "split", " " )
## simplification of arguments
a <- 1
b <- 5:8
## Not run:
python.call("concat", a, b)
## End(Not run)
# using function I()
python.call("concat", I(a), b)
# setting as.is = TRUE
python.call("concat", a, b, as.is = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.