Learn R Programming

PythonInR (version 0.1-12)

BEGIN.Python: Execute Python interactively from within R

Description

The function BEGIN.Python starts an Python read-eval-print loop.

Usage

BEGIN.Python()

Arguments

Value

Returns the entered code as character, code lines which throw an exception are omitted.

Details

BEGIN.Python emulates the behavior of the Python terminal and therefore allows interactive Python code development from within R.

Examples

Run this code
# NOT RUN {
code <-
BEGIN.Python()
import os
os.getcwd()
dir(os)
x = 3**3
for i in xrange(10):
    if (i > 5):
        print(i)

END.Python
## NOTE: BEGIN.Python returns the successfully executed code as character.
cat(code, sep="\n")
pyGet0("x")
# }

Run the code above in your browser using DataLab