Table Of Contents

Previous topic

pyAttach

Next topic

pyConnect

This Page

pyCall

Call a callable Python object from within R.

The args and kwargs are transformed to Python variables by the default conversion. More information about the type conversion can be found in the vignette.

Usage

pyCall(callableObj, args = NULL, kwargs = NULL, autoTypecast = TRUE,
  simplify = TRUE)

Arguments

callableObj   a character string giving the name of the desired callable Python object.
args   an optional list of arguments passed to the callable.
kwargs   an optional list of named arguments passed to the callable.
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 to R lists.

Examples

pyCall("sum", args=list(1:3))

## define a new function with the name fun
pyExec('
def fun(**kwargs):
    return([(key, value) for key, value in kwargs.items()])
')
pyCall("fun", kwargs=list(a=1, f=2, x=4))