Description Usage Arguments Details Examples
A convenience function to call the Python function import and creating virtual Python objects for the imported objects in R.
1 | pyImport(import, from = NULL, as = NULL, env = parent.frame())
|
import |
a character giving the names of the objects to import. |
from |
an optional character string giving the name of the module. |
as |
an optional string defining an alias for the module name. |
env |
an optional environment where the virtual Python objects are assigned to. |
The function pyImport works like the import function in Python.
The function pyImport has a special behavior for the packages numpy and pandas. For these two packages pyImport does not only import numpy but also register their alias in pyOptions. To be found when pySet is used with the option useNumpy set to TRUE.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | pyImport("os")
## Not run:
#NOTE: The following does not only import numpy but also register the
# alias in the options under the name "numpyAlias".
# The same is done for pandas, the default alias for pandas and numpy
# are respectively "pandas" and "numpy". The numpyAlias is used
# when calling pySet with the pyOption useNumpy set to TRUE.
pyOptions("numpyAlias")
pyImport("numpy", as="np")
pyOptions("numpyAlias")
pyImport("pandas", as="pd")
pyImport(c("getcwd", "sep"), from="os")
getcwd()
sep
sep = "Hello R!"
pyExecp("sep")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.