py_builtin | R Documentation |
Get 'Python' built-in object
py_builtin(name, convert = TRUE)
name |
object name |
convert |
see |
A python built-in object specified by name
if(interactive() && ants_available()) {
# ------ Basic case: use python `int` as an R function ---------
py_int <- py_builtin("int")
# a is an R object now
a <- py_int(9)
print(a)
class(a)
# ------ Use python `int` as a Python function -----------------
py_int2 <- py_builtin("int", convert = FALSE)
# b in a python object
b <- py_int2(9)
# There is no '[1] ' when printing
print(b)
class(b)
# convert to R object
py_to_r(b)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.