Description Usage Arguments Details Value Examples
Calls Python functions and methods from R
1 2 | pithon.call( py.foo, ..., simplify = TRUE, as.is = FALSE, instance.name="" )
pithon.method.call( py.object, py.method, ..., instance.name="" )
|
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 done |
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 |
instance.name |
if specified, use the Python instance with this name |
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 | if (pithon.available())
{
pithon.call( "len", 1:3 )
a <- 1:4
b <- 5:8
pithon.exec( "def concat(a,b): return a+b" )
pithon.call( "concat", a, b)
pithon.assign( "a", "hola hola" )
pithon.method.call( "a", "split", " " )
} else {
print("Unable to execute python")
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.