pySource: Reads mixed R and Python code from a file

Description Usage Arguments Details Examples

View source: R/PySource.R

Description

The function BEGIN.Python allows interactive development but doesn't work in combination with the function source. Therefore pySource provides an alternative to the function source which also can handle BEGIN.Python statements.

Usage

1
2
3
4
5
pySource(file, local = FALSE, echo = verbose, print.eval = echo,
  verbose = getOption("verbose"), prompt.echo = getOption("prompt"),
  max.deparse.length = 150, chdir = FALSE,
  encoding = getOption("encoding"), continue.echo = getOption("continue"),
  skip.echo = 0, keep.source = getOption("keep.source"))

Arguments

file

a character string giving the pathname of the file.

local

see documentation of source

echo

see documentation of source

print.eval

see documentation of source

verbose

see documentation of source

prompt.echo

see documentation of source

max.deparse.length

see documentation of source

chdir

see documentation of source

encoding

see documentation of source

continue.echo

see documentation of source

skip.echo

see documentation of source

keep.source

see documentation of source

Details

The function pySource works similar to source, but code which is enclosed between BEGIN.Python and END.Python is replaced by pyExec and the quoted version of the code.

Examples

1
2
3
4
5
6
7
## Not run: 
writeLines(c("x <- 3", "BEGIN.Python()", 
             "x=3**3", "print(3*u'Hello R!\\n')", 
             "END.Python"), "myMixedCode.R")
pySource("myMixedCode.R")

## End(Not run)

PythonInR documentation built on May 2, 2019, 5:17 p.m.