Import the specified Python module, making it available for use from R.
1 2 3 4 5 6 7
The name of the Python module.
An alias for module name (affects names of R classes). Note that this is an advanced parameter that should generally only be used in package development (since it affects the S3 name of the imported class and can therefore interfere with S3 method dispatching).
Boolean; should Python objects be automatically converted
to their R equivalent? If set to
Boolean; delay loading the module until it is first used?
The path from which the module should be imported.
An R object wrapping a Python module. Module attributes can be accessed
$ operator, or via
Python's built-in functions (e.g.
len()) can be accessed via Python's
built-in module. Because the name of this module has changed between Python 2
and Python 3, we provide the function
import_builtins() to abstract over
that name change.
delay_load parameter accepts a variety of inputs. If you just need to
ensure your module is lazy-loaded (e.g. because you are a package author and
want to avoid initializing Python before the user has explicitly requested it),
TRUE is normally the right choice.
You can also provide a list of named functions, which act as callbacks to be run when the module is later loaded. For example:
1 2 3 4 5 6 7 8 9 10 11 12
Alternatively, if you supply only a single function, that will be treated as
import_from_path() can be used in you need to import a module from an arbitrary
filesystem path. This is most commonly used when importing modules bundled with an
R package – for example:
1 2 3 4 5
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.