Description Usage Arguments Value Examples
py.get
get the value of Python and returns it to the R environment.
Objects are serialized as JSON strings on Python with json.dumps
,
are transferred to R and are converted back to an R value using
jsonlite::fromJSON
.
1 |
var.name |
a character string containing a valid Python variable name |
json.opt.ret |
explicit arguments to pass to |
an R object containing the variable value after serialization to JSON in the Python environment and deserialization from JSON in the R environment
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | py.assign("a", 1:4)
py.get("a")
# [1] 1 2 3 4
py.assign("b", list(one = 1, foo = "bar"))
str(py.get("b"))
# List of 2
# $ foo: chr "bar"
# $ one: int 1
py.exec("import math")
py.get("math.pi")
# [1] 3.141593
## Not run:
py.rm("notset")
py.get("notset")
# Error in py.get("notset") (from py.get.R#60) : Traceback (most recent call last):
# File "<string>", line 2, in <module>
# NameError: name 'notset' is not defined
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.