import: Import a Python module

Description Usage Arguments Details Value Examples

View source: R/python.R

Description

Import the specified Python module for calling from R.

Usage

1
2
3
4
5
6
7
import(module, as = NULL, convert = TRUE, delay_load = FALSE)

import_main(convert = TRUE)

import_builtins(convert = TRUE)

import_from_path(module, path = ".", convert = TRUE)

Arguments

module

Module name

as

Alias for module name (affects names of R classes)

convert

TRUE to automatically convert Python objects to their R equivalent. If you pass FALSE you can do manual conversion using the py_to_r() function.

delay_load

TRUE to delay loading the module until it is first used. FALSE to load the module immediately. If a function is provided then it will be called once the module is loaded. If a list containing on_load() and on_error(e) elements is provided then on_load() will be called on successful load and on_error(e) if an error occurs.

path

Path to import from

Details

The import_from_path function imports a Python module from an arbitrary filesystem path (the directory of the specified python script is automatically added to the sys.path).

Value

A Python module

Examples

1
2
3
4
5
## Not run: 
main <- import_main()
sys <- import("sys")

## End(Not run)

Mormukut11/R-interface-to-Python documentation built on May 21, 2019, 9:36 a.m.