Description Usage Arguments Details Value Note Examples
The function pyGet gets Python objects by name and transforms them into R objects.
1 |
key |
a string specifying the name of a Python object. |
autoTypecast |
an optional logical value, default is TRUE, specifying if the return values should be automatically typecasted if possible. |
simplify |
an optional logical value, if TRUE R converts Python lists into R vectors whenever possible, else it translates Python lists always into R lists. |
Since any Python object can be transformed into one of the basic
data types it is up to the user to do so up front. More information
about the type conversion can be found in the README file or at
http://pythoninr.bitbucket.org/.
Returns the specified Python object converted into an R object if possible, else a virtual Python object.
pyGet always returns a new object, if you want to create a R representation of an existing Python object use pyGet0 instead.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ## get a character of length 1
pyGet("__name__")
## get a character of length 1 > 1
pyGet("sys.path")
## get a list
pyGet("sys.path", simplify = FALSE)
## get a PythonInR_List
x <- pyGet("sys.path", autoTypecast = FALSE)
x
class(x)
## get an object where no specific transformation to R is defined
## this example also shows the differnces between pyGet and pyGet0
pyExec("import datetime")
## pyGet creates a new Python variable where the return value of pyGet is
## stored the name of the new reference is stored in x$py.variableName.
x <- pyGet("datetime.datetime.now().time()")
x
class(x)
x$py.variableName
## pyGet0 never creates a new Python object, objects which can be transformed
## to R objects are transformed. For all other objects an PythonInR_Object is created.
y <- pyGet0("datetime.datetime.now().time()")
y
## An important difference is that the evaluation of x always will return the same
## time, the evaluation of y always will give the new time.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.