-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Pull Request - Fixes #333 - Companion of insightsengineering/teal.code#218 #### Blockers - `{teal.code}` - [ ] Merge insightsengineering/teal.code#218 #### Changes description - [x] Adds `names()` function - [x] Setter is implemented but throws warning (does nothing) - [x] Deprecates `datanames()` getter and setter - [x] Adapt tests to new API - [x] Update NEWS - [ ] Review documentation - [ ] Review vignettes <!-- - [ ] `{teal}` review vignettes - [ ] `{teal}` Review use of `datanames() - [ ] `{tmg}` Review use of `datanames() - [ ] `{tmc}` Review use of `datanames() - [ ] `{teal.gallery}` Review use of `datanames() - [ ] `{tlg.catalog}` Review use of `datanames() - [ ] `{teal.osprey}` Review use of `datanames() - [ ] `{teal.goshawk}` Review use of `datanames() - [ ] `{teal.*}` Review use of `datanames() --> --------- Signed-off-by: André Veríssimo <[email protected]> Co-authored-by: Dawid Kałędkowski <[email protected]>
- Loading branch information
1 parent
eca9695
commit 3d899ee
Showing
26 changed files
with
363 additions
and
378 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
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
This file was deleted.
Oops, something went wrong.
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,41 @@ | ||
#' Names of data sets in `teal_data` object | ||
#' | ||
#' Functions to get the names of a `teal_data` object. | ||
#' The names are obtained from the objects listed in the `qenv` environment. | ||
#' | ||
#' Objects named with a `.` (dot) prefix will be ignored and not returned. | ||
#' To get the names of all objects, use `ls(x, all.names = TRUE)`, however, it | ||
#' will not group the names by the join_keys topological structure. | ||
#' | ||
#' @param x A (`teal_data`) object to access or modify. | ||
#' | ||
#' @return A character vector of names. | ||
#' | ||
#' @examples | ||
#' td <- teal_data(iris = iris) | ||
#' td <- within(td, mtcars <- mtcars) | ||
#' names(td) | ||
#' | ||
#' td <- within(td, .CO2 <- CO2) | ||
#' names(td) # '.CO2' will not be returned | ||
#' | ||
#' @export | ||
names.teal_data <- function(x) { | ||
# Sorting from `ls` can be safely done as environments don't have any order | ||
# nor support numeric-index subsetting | ||
envir <- as.environment(x) | ||
.get_sorted_names(ls(envir = envir), join_keys(x), envir) | ||
} | ||
|
||
#' @export | ||
length.teal.data <- function(x) length(ls(x)) | ||
|
||
#' @keywords internal | ||
.get_sorted_names <- function(datanames, join_keys, env) { | ||
child_parent <- sapply(datanames, parent, x = join_keys, USE.NAMES = TRUE, simplify = FALSE) | ||
|
||
union( | ||
intersect(unlist(topological_sort(child_parent)), ls(env, all.names = TRUE)), | ||
datanames | ||
) | ||
} |
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
Oops, something went wrong.