Skip to content

Commit 04cb357

Browse files
committed
merge subseting sections of [ and get_code
1 parent 5dc7720 commit 04cb357

File tree

5 files changed

+30
-17
lines changed

5 files changed

+30
-17
lines changed

R/qenv-constructor.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@
1818
#' A `qenv` inherits from the `environment` class, behaves like an environment, and has the
1919
#' following characteristics:
2020
#'
21-
#' - The environment is locked, and data modification is only possible through the `eval_code()`
21+
#' - `qenv` environment is locked, and data modification is only possible through the `eval_code()`
2222
#' and `within()` functions.
2323
#' - It stores metadata about the code used to create the data.
24-
#' - Is immutable which means that each code evaluation does not modify the original `qenv` object
25-
#' directly.
24+
#' - Is immutable which means that each code evaluation does not modify the original `qenv`
25+
#' environment directly. See the following code:
26+
#' ```
27+
#' q1 <- qenv()
28+
#' q2 <- eval_code(q1, "a <- 1")
29+
#' identical(q1, q2) # FALSE
30+
#' ```
2631
#'
2732
#' @name qenv
2833
#'

R/qenv-eval_code.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#' Evaluate code in `qenv`
22
#'
33
#' @details
4+
#'
45
#' `eval_code()` evaluates given code in the `qenv` environment and appends it to the `code` slot.
56
#' Thus, if the `qenv` had been instantiated empty, contents of the environment are always a result of the stored code.
67
#' The `qenv` object is immutable, even though it inherits from the environment class, which is typically mutable by
@@ -14,7 +15,7 @@
1415
#' `expression` being a result of `parse(keep.source = TRUE)`.
1516
#'
1617
#' @return
17-
#' `eval_code` returns a `qenv` object with `expr` evaluated or `qenv.error` if evaluation fails.
18+
#' `eval_code` and `within` returns a `qenv` object with `expr` evaluated or `qenv.error` if evaluation fails.
1819
#'
1920
#' @examples
2021
#' # evaluate code in qenv

R/qenv-extract.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#'
2-
#' @section Subsetting:
3-
#' `x[names]` subsets objects in `qenv` environment and limit the code to the necessary needed to build limited objects.
2+
#' @section Subsetting by the `names`:
3+
#'
4+
#' `x[names]` subsets `qenv` environment and limits the code to the necessary needed to build limited objects.
45
#' `...` passes parameters to further methods.
56
#'
67
#' @param x (`qenv`)

R/qenv-get_code.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ NULL
3232
#' @param ... see `Details`
3333
#'
3434
#'
35-
#' @section Extracting dataset-specific code:
36-
#' When `names` for `get_code` is specified, the code returned will be limited to the lines needed to _create_
35+
#' @section Subsetting by the `names`:
36+
#'
37+
#' `get_code(x, names)` limits the returned code to contain only those lines needed to _create_
3738
#' the requested objects. The code stored in the `qenv` is analyzed statically to determine
3839
#' which lines the objects of interest depend upon. The analysis works well when objects are created
3940
#' with standard infix assignment operators (see `?assignOps`) but it can fail in some situations.

man/qenv.Rd

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

0 commit comments

Comments
 (0)