Skip to content

Commit

Permalink
docs: small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Oct 31, 2024
1 parent 709265f commit 1fe8b18
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ S3method(c,qenv)
S3method(c,qenv.error)
S3method(length,qenv)
S3method(length,qenv.error)
S3method(names,qenv.error)
S3method(within,qenv)
S3method(within,qenv.error)
export(concat)
Expand Down
2 changes: 1 addition & 1 deletion R/qenv-eval_code.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ setMethod("eval_code", signature = c("qenv", "character"), function(object, code
{
eval(single_call, envir = object@.xData)
if (!identical(parent.env(object@.xData), parent.env(.GlobalEnv))) {
# needed to make sure that @env is always a sibling of .GlobalEnv
# needed to make sure that @.xData is always a sibling of .GlobalEnv
# could be changed when any new package is added to search path (through library or require call)
parent.env(object@.xData) <- parent.env(.GlobalEnv)
}
Expand Down
17 changes: 7 additions & 10 deletions R/qenv-get_env.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#' Access environment included in `qenv`
#'
#' The access of environment included in `qenv@env` allows to e.g. list object names included in `qenv@env` slot.
#' The access of environment included in the `qenv` that contains all data objects.
#'
#' @param object (`qenv`)
#' @param object (`qenv`).
#'
#' @return An `environment` stored in `qenv@env` slot.
#' @return An `environment` stored in `qenv` slot with all data objects.
#'
#' @examples
#' q <- qenv()
Expand All @@ -13,7 +13,8 @@
#' b <- data.frame(x = 1:10)
#' })
#' get_env(q1)
#' ls(get_env(q1))
#'
#' ls(get_env(q1)) # list objects in the environment
#'
#' @aliases get_env,qenv-method
#' @aliases get_env,qenv.error-method
Expand All @@ -23,10 +24,6 @@ setGeneric("get_env", function(object) {
standardGeneric("get_env")
})

setMethod("get_env", "qenv", function(object) {
object@.xData
})
setMethod("get_env", "qenv", function(object) [email protected])

setMethod("get_env", "qenv.error", function(object) {
object
})
setMethod("get_env", "qenv.error", function(object) object)
5 changes: 4 additions & 1 deletion R/qenv-get_var.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@ setMethod("[[", signature = c("qenv", "ANY"), function(x, i) {
))
}

#' @export
names.qenv.error <- function(x) NULL

#' @export
`$.qenv.error` <- function(x, name) {
# Must allow access of elements in qenv.error object (message, call, trace, ...)
# Otherwise, it will enter an infinite recursion with the `conditionMessage(x)` call.
if (name %in% names(x)) {
if (exists(name, x)) {
return(NextMethod("$", x))
}

Expand Down
4 changes: 2 additions & 2 deletions R/qenv-join.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
#' # Error message will occur
#'
#' # Check the value of temporary variable i in both objects
#' x@env$i # Output: 2
#' y@env$i # Output: 3
#' x@.xData$i # Output: 2
#' y@.xData$i # Output: 3
#' ```
#' `join()` fails to provide a proper result because of the temporary variable `i` exists
#' in both objects but has different value.
Expand Down
9 changes: 5 additions & 4 deletions man/get_env.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/join.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1fe8b18

Please sign in to comment.