create_simple_get_function: Create a function that creates an object and assigns it to a...

View source: R/utils_environments_namespaces.R

create_simple_get_functionR Documentation

Create a function that creates an object and assigns it to a namespace the first time it's called and subsequently retrieves it from the namespace thereafter.

Description

Useful when the object depends on a long running task such as a database query.

Usage

create_simple_get_function(obj_nm, env_expr, call_expr, as_character = FALSE)

Arguments

obj_nm

chr Name of the object

env_expr

expr/chr name of the namespace to assign the object to, or an expression that returns the environment to assign to

call_expr

expr The code used to construct the object if the object hasn't already been constructed

as_character

Should the function return code as a character? (Default is an expression)

Value

chr The function at the console for copy/paste

Examples

create_simple_get_function("mt_cars", .GlobalEnv, dplyr::mutate(mtcars, cyl = as.character(cyl)))

yogat3ch/UU documentation built on May 31, 2024, 10:14 p.m.