Learn R Programming

PythonInR (version 0.1-12)

pyExec: Executes multiple lines of Python code from within R

Description

The function pyExec allows to execute multiple lines of python code from within R.

Usage

pyExec(code)

Arguments

code

a string of Python code to be executed in Python.

Details

Since pyExec can execute multiple lines, it is the obvious choice for defining Python functions or running small scripts where no return value is needed.

Examples

Run this code
# NOT RUN {
pyExec('
print("The following line will not appear in the R terminal!")
"Hello" + " " + "R!"
print("NOTE: pyExecp would also show the line above!")
print("The following line will appear in the R terminal!")
print("Hello" + " " + "R!")
')
# }

Run the code above in your browser using DataLab