Description Usage Arguments Details Value References Examples
View source: R/pithon.assign.R
Functions that assign and get Python variables from R.
1 2 | pithon.assign( var.name, value, ..., instance.name="" )
pithon.get( var.name, instance.name="" )
|
var.name |
a character string containing a Python variable name |
value |
an R object whose equivalent will be assigned to the variable in Python |
... |
arguments to pass to RJSONIO's toJSON function |
instance.name |
if specified, use the Python instance with this name |
These functions can assign values to variables in Python as well as get their values back to R. Objects are serialized as JSON strings while being transferred between R and Python.
Function pithon.get
returns a R version of the Python variable py.var
.
http://code.google.com/p/simplejson
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | if (pithon.available())
{
a <- 1:4
pithon.assign( "a", a )
pithon.exec( "b = len( a )" )
pithon.get( "b" )
pithon.exec( "import math" )
p <- pithon.get( "math.pi" )
} else {
print("Unable to execute python")
}
pithon.set.executable("python3", instance.name="v3")
if (pithon.available("v3"))
{
pithon.assign("x", 123.456, instance.name="v3")
pithon.get("x", "v3")
} else {
print("Unable to execute python3")
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.