-
-
Notifications
You must be signed in to change notification settings - Fork 8
Update lifecycle badges #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b98c0ce
f039848
fcf46ed
a3da6e9
2df511d
3ceb4f7
2c25b4d
aa1a5ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,45 +5,12 @@ | |
| #' Instead of [get_var()] use native \R operators/functions: | ||
| #' `x[[name]]`, `x$name` or [get()]: | ||
| #' | ||
| #' Retrieve variables from the `qenv` environment. | ||
| #' | ||
| #' @param object,x (`qenv`) | ||
| #' @param var,i (`character(1)`) variable name. | ||
| #' | ||
| #' @return The value of required variable (`var`) within `qenv` object. | ||
| #' | ||
| #' @examples | ||
| #' q <- qenv() | ||
| #' q1 <- eval_code(q, code = quote(a <- 1)) | ||
| #' q2 <- eval_code(q1, code = "b <- a") | ||
| #' get_var(q2, "b") | ||
| #' | ||
| #' @aliases get_var,qenv,character-method | ||
| #' @aliases get_var,qenv.error,ANY-method | ||
| #' @param ... function is deprecated. | ||
| #' @param x (`qenv`) | ||
| #' @param i (`character(1)`) variable name. | ||
| #' | ||
| #' @export | ||
| setGeneric("get_var", function(object, var) { | ||
| dev_suppress(object) | ||
| standardGeneric("get_var") | ||
| }) | ||
|
|
||
| setMethod("get_var", signature = c("qenv", "character"), function(object, var) { | ||
| lifecycle::deprecate_soft("0.6.0", "get_var()", "base::get()") | ||
| tryCatch( | ||
| get(var, envir = object@.xData, inherits = FALSE), | ||
| error = function(e) { | ||
| message(conditionMessage(e)) | ||
| NULL | ||
| } | ||
| ) | ||
| }) | ||
|
|
||
| setMethod("get_var", signature = c("qenv.error", "ANY"), function(object, var) { | ||
| stop(errorCondition( | ||
| list(message = conditionMessage(object)), | ||
| class = c("validation", "try-error", "simpleError") | ||
| )) | ||
| }) | ||
| get_var <- function(...) lifecycle::deprecate_stop("0.6.0", "get_var()", "base::get()") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does It suppose to be |
||
|
|
||
| #' @rdname get_var | ||
| #' @export | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,152 +1,13 @@ | ||
| #' Join `qenv` objects | ||
| #' | ||
| #' @description | ||
| #' Checks and merges two `qenv` objects into one `qenv` object. | ||
| #' `r lifecycle::badge("deprecated")` | ||
| #' Instead of [join()] use [c()]. | ||
| #' | ||
| #' The `join()` function is superseded by the `c()` function. | ||
| #' | ||
| #' @details | ||
| #' Any common code at the start of the `qenvs` is only placed once at the start of the joined `qenv`. | ||
| #' This allows consistent behavior when joining `qenvs` which share a common ancestor. | ||
| #' See below for an example. | ||
| #' | ||
| #' There are some situations where `join()` cannot be properly performed, such as these three scenarios: | ||
| #' 1. Both `qenv` objects contain an object of the same name but are not identical. | ||
| #' | ||
| #' Example: | ||
| #' | ||
| #' ```r | ||
| #' x <- eval_code(qenv(), expression(mtcars1 <- mtcars)) | ||
| #' y <- eval_code(qenv(), expression(mtcars1 <- mtcars['wt'])) | ||
| #' | ||
| #' z <- c(x, y) | ||
| #' # Error message will occur | ||
| #' ``` | ||
| #' In this example, `mtcars1` object exists in both `x` and `y` objects but the content are not identical. | ||
| #' `mtcars1` in the `x qenv` object has more columns than `mtcars1` in the `y qenv` object (only has one column). | ||
| #' | ||
| #' 2. `join()` will look for identical code elements in both `qenv` objects. | ||
| #' The index position of these code elements must be the same to determine the evaluation order. | ||
| #' Otherwise, `join()` will throw an error message. | ||
| #' | ||
| #' Example: | ||
| #' ```r | ||
| #' common_q <- eval_code(qenv(), expression(v <- 1)) | ||
| #' x <- eval_code( | ||
| #' common_q, | ||
| #' "x <- v" | ||
| #' ) | ||
| #' y <- eval_code( | ||
| #' common_q, | ||
| #' "y <- v" | ||
| #' ) | ||
| #' z <- eval_code( | ||
| #' y, | ||
| #' "z <- v" | ||
| #' ) | ||
| #' q <- c(x, y) | ||
| #' join_q <- c(q, z) | ||
| #' # Error message will occur | ||
| #' | ||
| #' # Check the order of evaluation based on the id slot | ||
| #' ``` | ||
| #' The error occurs because the index position of common code elements in the two objects is not the same. | ||
| #' | ||
| #' 3. The usage of temporary variable in the code expression could cause `join()` to fail. | ||
| #' | ||
| #' Example: | ||
| #' ```r | ||
| #' common_q <- qenv() | ||
| #' x <- eval_code( | ||
| #' common_q, | ||
| #' "x <- numeric(0) | ||
| #' for (i in 1:2) { | ||
| #' x <- c(x, i) | ||
| #' }" | ||
| #' ) | ||
| #' y <- eval_code( | ||
| #' common_q, | ||
| #' "y <- numeric(0) | ||
| #' for (i in 1:3) { | ||
| #' y <- c(y, i) | ||
| #' }" | ||
| #' ) | ||
| #' q <- join(x,y) | ||
| #' # Error message will occur | ||
| #' | ||
| #' # Check the value of temporary variable i in both objects | ||
| #' x$i # Output: 2 | ||
| #' y$i # Output: 3 | ||
| #' ``` | ||
| #' `c()` fails to provide a proper result because of the temporary variable `i` exists | ||
| #' in both objects but has different value. | ||
| #' To fix this, we can set `i <- NULL` in the code expression for both objects. | ||
| #' ```r | ||
| #' common_q <- qenv() | ||
| #' x <- eval_code( | ||
| #' common_q, | ||
| #' "x <- numeric(0) | ||
| #' for (i in 1:2) { | ||
| #' x <- c(x, i) | ||
| #' } | ||
| #' # dummy i variable to fix it | ||
| #' i <- NULL" | ||
| #' ) | ||
| #' y <- eval_code( | ||
| #' common_q, | ||
| #' "y <- numeric(0) | ||
| #' for (i in 1:3) { | ||
| #' y <- c(y, i) | ||
| #' } | ||
| #' # dummy i variable to fix it | ||
| #' i <- NULL" | ||
| #' ) | ||
| #' q <- c(x,y) | ||
| #' ``` | ||
| #' | ||
| #' @param x (`qenv`) | ||
| #' @param y (`qenv`) | ||
| #' | ||
| #' @return `qenv` object. | ||
| #' | ||
| #' @examples | ||
| #' q <- qenv() | ||
| #' q1 <- eval_code(q, expression(iris1 <- iris, mtcars1 <- mtcars)) | ||
| #' q2 <- q1 | ||
| #' q1 <- eval_code(q1, "iris2 <- iris") | ||
| #' q2 <- eval_code(q2, "mtcars2 <- mtcars") | ||
| #' qq <- join(q1, q2) | ||
| #' cat(get_code(qq)) | ||
| #' | ||
| #' common_q <- eval_code(q, quote(x <- 1)) | ||
| #' y_q <- eval_code(common_q, quote(y <- x * 2)) | ||
| #' z_q <- eval_code(common_q, quote(z <- x * 3)) | ||
| #' join_q <- join(y_q, z_q) | ||
| #' # get_code only has "x <- 1" occurring once | ||
| #' cat(get_code(join_q)) | ||
| #' | ||
| #' @include qenv-errors.R | ||
| #' @param ... function is deprecated. | ||
| #' | ||
| #' @name join | ||
| #' @rdname join | ||
| #' @aliases join,qenv,qenv-method | ||
| #' @aliases join,qenv,qenv.error-method | ||
| #' @aliases join,qenv.error,ANY-method | ||
| #' | ||
| #' @export | ||
| setGeneric("join", function(x, y) standardGeneric("join")) | ||
|
|
||
| setMethod("join", signature = c("qenv", "qenv"), function(x, y) { | ||
| lifecycle::deprecate_soft("0.6.0", "join()", "c()") | ||
| c(x, y) | ||
| }) | ||
|
|
||
| setMethod("join", signature = c("qenv", "qenv.error"), function(x, y) { | ||
| lifecycle::deprecate_soft("0.6.0", "join()", "c()") | ||
| y | ||
| }) | ||
|
|
||
| setMethod("join", signature = c("qenv.error", "ANY"), function(x, y) { | ||
| lifecycle::deprecate_soft("0.6.0", "join()", "c()") | ||
| x | ||
| }) | ||
| join <- function(...) lifecycle::deprecate_stop("0.6.0", "join()", "c()") |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.