add_imports: Import Packages & Functions

Description Usage Arguments See Also Examples

Description

Import packages & functions Python style. Use the forms import PACKAGE, import PACKAGE as ALIAS, or from PACKAGE import FUN1, FUN2, FUN_N. Note that if a package is not installed add_imports will attempt to install from CRAN. The from PACKAGE import FUN1, FUN2, FUN_N even allows importing non-exported functions into the global environment.

Usage

1
add_imports(..., options = NULL, pos = 1, envir = as.environment(pos))

Arguments

options

A list of named arguments to pass to install.packages.

pos

Where to do the assignment.

envir

The environment to use.

...

Python style commands for importing packages and functions.

See Also

install.packages

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
## Not run: 
add_imports('import lattice as lat')
lat::xyplot
get_imports()

file_ext
add_imports('from lattice import xyplot, qq')
file_ext
get_imports_functions()

## Removing packages and functions
get_imports()
get_imports_functions()
clear_imports()
get_imports()
get_imports_functions()
lat::xyplot
file_ext

## Options
add_imports(list(repos = "http://cran.us.r-project.org"),
  'import dplyr as dp', 'import ggplot2 as gg'
)
clear_imports()

## Mutli-line
add_imports('

import dplyr as dp
import ggplot2 as gg
import tidyr
from plyr import l_ply, rbind.fill

')

l_ply
dp::arrange
dp:::wrap

clear_imports()

## End(Not run)

trinker/pysty documentation built on May 31, 2019, 9:42 p.m.