Skip to content

Commit 5c0ef7d

Browse files
committed
doc: adds section to qenv constructor
1 parent 9904570 commit 5c0ef7d

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

R/qenv-constructor.R

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,31 @@
1010
#' `qenv()` instantiates a `qenv` with an empty environment.
1111
#' Any changes must be made by evaluating code in it with `eval_code` or `within`, thereby ensuring reproducibility.
1212
#'
13+
#'
1314
#' `new_qenv()` (`r badge("deprecated")` and not recommended)
1415
#' can instantiate a `qenv` object with data in the environment and code registered.
1516
#'
17+
#' @section Environment:
18+
#'
19+
#' The `qenv` object behaves as an environment that is locked and can be used as
20+
#' as a argument to with many functions that accept `environment`, among the
21+
#' most relevant are: `names()`, `ls()`, `get()`, `exists()`, `parent.env()`,
22+
#' `{l,s,v}apply` family, `local`, `as.environment()`, `is.environment()`, `as.list()`, ...
23+
#'
24+
#' `qenv` should not be used with `cbind()` and `env.profile()` functions as it
25+
#' has unexpected behavior.
26+
#' Instead, `get_env()` or `as.environment()` should be used before calling any
27+
#' problematic function.
28+
#'
29+
#' Similarly, `rlang` functions related to environments cannot be used directly
30+
#' with `qenv` and should be used with `teal.code::get_env()`/`as.environment()`.
31+
#'
32+
#' ```r
33+
#' q <- qenv()
34+
#' rlang::env_clone(as.environment(q))
35+
#' rlang::env_clone(get_env(q))
36+
#' ```
37+
#'
1638
#' @name qenv
1739
#'
1840
#' @return `qenv` and `new_qenv` return a `qenv` object.

man/qenv.Rd

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)