-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#' | ||
#' @section Subsetting: | ||
#' `x[names]` subsets objects in `teal_data` environment and limit the code to the necessary needed to build limited | ||
#' objects. | ||
#' | ||
#' @param names (`character`) names of objects included in `teal_subset` to subset | ||
#' @param x (`teal_data`) | ||
#' | ||
#' @examples | ||
#' | ||
#' # Subsetting | ||
#' data <- teal_data() | ||
#' data <- eval_code(data, "a <- 1;b<-2") | ||
#' data["a"] | ||
#' data[c("a", "b")] | ||
#' | ||
#' join_keys(data) <- join_keys(join_key("a", "b", "x")) | ||
#' join_keys(data["a"]) # should show empty keys | ||
#' join_keys(data["b"]) | ||
#' join_keys(data)["a"] # should show empty keys | ||
#' join_keys(data)["b"] | ||
#' | ||
#' @rdname teal_data | ||
#' | ||
#' @export | ||
`[.teal_data` <- function(x, names) { | ||
checkmate::assert_class(names, "character") | ||
names_in_env <- intersect(names, ls(get_env(x))) | ||
if (!length(names_in_env)) { | ||
return(teal_data()) | ||
} | ||
|
||
subset_qenv <- getFromNamespace("[.qenv", "teal.code") | ||
x <- subset_qenv(x, names_in_env) | ||
x@join_keys <- x@join_keys[names_in_env] | ||
|
||
x | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.