import: python-style import

Description Usage Arguments Value Examples

Description

import a single function from a file (instead of getting them all with 'source()')

Usage

1
import(what, from, msg = TRUE)

Arguments

what

function to be imported (*not quoted*)

from

path to file that defines 'what' (character)

msg

whether to print a message on success ("func X was imported"); defaults to 'TRUE'

Value

no return value

Examples

1
2
3
4
5
6
# usage example (assumes `boosh()` is defined in "util.r")
import(what=boosh, from="util.r") # `boosh()` gets created in calling env
rm(boosh) # clear `boosh()` from ws
blaowwie <- function(){
  import(boosh, from="util.r"); boosh("blah1","blah2")}
blaowwie() # `boosh()` will *not* be created in calling env of `blaowwie()` 

lefft/lefftpack documentation built on May 8, 2019, 1:13 p.m.