Previous topic

pyVersion

Next topic

Type Casting

This Page

PythonInR CheatsheetΒΆ

Command Short Description Example Usage
BEGIN.Python Start a Python read-eval-print loop BEGIN.Python() print("Hello" + " " + "R!") END.Python
pyAttach Attach a Python object to an R environment pyAttach("os.getcwd", .GlobalEnv)
pyCall Call a callable Python object pyCall("pow", list(2,3), namespace="math")
pyConnect Connect R to Python pyConnect()
pyDict Create a representation of a Python dict in R myNewDict <- pyDict('myNewDict', list(p=2, y=9, r=1))
pyDir The Python function dir (similar to ls) pyDir()
pyExec Execute Python code pyExec('some_python_code = "executed"')
pyExecfile Execute a file (like source) pyExecfile("myPythonFile.py")
pyExecg Execute Python code and get all assigned variables pyExecg('some_python_code = "executed"')
pyExecp Execute and print Python Code pyExecp('"Hello" + " " + "R!"')
pyExit Close Python pyExit()
pyFunction Create a representation of a Python function in R pyFunction(key)
pyGet Get a Python variable pyGet('myPythonVariable')
pyGet0 Get a Python variable pyGet('myPythonVariable')
pyHelp Python help pyHelp("help")
pyImport Import a Python module pyImport("numpy", "np")
pyIsConnected Check if R is connected to Python pyIsConnected()
pyList Create a representation of a Python list in R pyList(key)
pyObject Create a representation of a Python object in R pyObject(key)
pyOptions A function to get and set some package options pyOptions("numpyAlias", "np")
pyPrint Print a Python variable from within R pyPrint("somePythonVariable")
pySet Set a R variable in Python pySet("pi", pi)
pySource A modified BEGIN.Python aware version of source pySource("myFile.R")
pyTuple Create a representation of a Python tuple in R pyTuple(key)
pyType Get the type of a Python variable pyType("sys")
pyVersion Returns the version of Python pyVersion()