Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
Merge branch 'main' into remove_backticks_cdisc@main

# Conflicts:
#	R/default_cdisc_join_keys.R
#	man/build_cdisc_join_keys.Rd
#	man/default_cdisc_join_keys.Rd
  • Loading branch information
m7pr committed Feb 5, 2024
2 parents ed7a8d3 + fc2e59e commit 2d9fc71
Show file tree
Hide file tree
Showing 23 changed files with 121 additions and 143 deletions.
27 changes: 14 additions & 13 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
Type: Package
Package: teal.data
Title: Data Model for 'teal' Applications
Version: 0.3.0.9042
Date: 2024-01-24
Version: 0.4.0.9001
Date: 2024-02-02
Authors@R: c(
person("Dawid", "Kaledkowski", , "[email protected]", role = c("aut", "cre")),
person("Aleksander", "Chlebowski", , "[email protected]", role = "aut"),
person("Dawid", "Kaledkowski", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-9533-457X")),
person("Aleksander", "Chlebowski", , "[email protected]", role = "aut",
comment = c(ORCID = "0000-0001-5018-6294")),
person("Marcin", "Kosinski", , "[email protected]", role = "aut"),
person("Andre", "Verissimo", , "[email protected]", role = "aut"),
person("Andre", "Verissimo", , "[email protected]", role = "aut",
comment = c(ORCID = "0000-0002-2212-339X")),
person("Pawel", "Rucki", , "[email protected]", role = "aut"),
person("Mahmoud", "Hallal", , "[email protected]", role = "aut"),
person("Nikolas", "Burkoff", role = "aut"),
Expand All @@ -18,8 +21,8 @@ Authors@R: c(
person("Dony", "Unardi", , "[email protected]", role = "rev"),
person("F. Hoffmann-La Roche AG", role = c("cph", "fnd"))
)
Description: Utilities for data transformations compatible with 'teal'
applications.
Description: Provides a 'teal_data' class as a unified data model for
'teal' applications focusing on reproducibility and relational data.
License: Apache License 2.0
URL: https://insightsengineering.github.io/teal.data/,
https://github.com/insightsengineering/teal.data/
Expand All @@ -33,8 +36,7 @@ Imports:
methods,
rlang (>= 1.1.0),
stats,
utils,
yaml
utils
Suggests:
knitr (>= 1.42),
rmarkdown (>= 2.19),
Expand All @@ -44,18 +46,17 @@ VignetteBuilder:
RdMacros:
lifecycle
Config/Needs/verdepcheck: mllg/checkmate, r-lib/lifecycle, r-lib/rlang,
yaml=vubiostat/r-yaml, yihui/knitr, rstudio/rmarkdown,
insightsengineering/teal.code, r-lib/testthat
yihui/knitr, rstudio/rmarkdown, insightsengineering/teal.code,
r-lib/testthat
Config/Needs/website: insightsengineering/nesttemplate
Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
Collate:
Collate:
'cdisc_data.R'
'data.R'
'default_cdisc_join_keys.R'
'formatters_var_labels.R'
'deprecated.R'
'dummy_function.R'
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export(dataset)
export(dataset_connector)
export(dataset_connector_file)
export(dataset_file)
export(default_cdisc_join_keys)
export(example_cdisc_data)
export(fun_cdisc_dataset_connector)
export(fun_dataset_connector)
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# teal.data 0.3.0.9042
# teal.data 0.4.0.9001

# teal.data 0.4.0

### Enhancements

Expand Down
2 changes: 1 addition & 1 deletion R/cdisc_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
cdisc_data <- function(...,
join_keys = teal.data::default_cdisc_join_keys[names(rlang::list2(...))],
code = character(0),
check = FALSE) {
check) {
teal_data(..., join_keys = join_keys, code = code, check = check)
}
10 changes: 10 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,13 @@
#' @source internal
#' @name rADVS
"rADVS"

#' List containing default joining keys for `CDISC` datasets
#'
#' This data object is created at loading time from `cdisc_datasets/cdisc_datasets.yaml`.
#'
#' @name default_cdisc_join_keys
#' @usage default_cdisc_join_keys
#' @docType data
#' @source internal
"default_cdisc_join_keys"
35 changes: 0 additions & 35 deletions R/default_cdisc_join_keys.R

This file was deleted.

4 changes: 2 additions & 2 deletions R/deprecated.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ NULL

.deprecate_function <- function(what, details) {
lifecycle::deprecate_stop(
when = "0.3.1",
when = "0.4.0",
what = what,
details = details
)
Expand Down Expand Up @@ -338,7 +338,7 @@ get_join_keys <- function(...) {
#' `r lifecycle::badge("deprecated")`
#'
#' In previous versions of `teal.data` labels were managed with `get_labels()`.
#' This function is deprecated as of `0.3.1`, use `col_labels` instead.
#' This function is deprecated as of `0.4.0`, use `col_labels` instead.
#' @export
get_labels <- function(...) {
.deprecate_function("get_labels()", "Use col_labels(data)")
Expand Down
19 changes: 14 additions & 5 deletions R/teal_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
#' @param code (`character`, `language`) optional code to reproduce the datasets provided in `...`.
#' Note this code is not executed and the `teal_data` may not be reproducible
#'
#' @param check (`logical`) reproducibility check - whether to perform a check that the pre-processing
#' code included in the object definitions actually produces those objects.
#' If `check` is true and preprocessing code is empty an error will be thrown.
#' @param check (`logical`) `r lifecycle::badge("deprecated")`
#' Use [verify()] to verify code reproducibility .
#'
#' @return A `teal_data` object.
#'
Expand All @@ -29,11 +28,21 @@
teal_data <- function(...,
join_keys = teal.data::join_keys(),
code = character(0),
check = FALSE) {
check) {
data_objects <- rlang::list2(...)
if (inherits(join_keys, "join_key_set")) {
join_keys <- teal.data::join_keys(join_keys)
}
if (!missing(check)) {
lifecycle::deprecate_stop(
when = "0.4.0",
"teal_data(
check = 'check argument is deprecated. Use `verify()` to verify code reproducibility.
Find more information on https://github.com/insightsengineering/teal/discussions/945'
)"
)
}

if (
checkmate::test_list(
data_objects,
Expand All @@ -42,7 +51,7 @@ teal_data <- function(...,
)
) {
lifecycle::deprecate_stop(
when = "0.3.1",
when = "0.4.0",
"teal_data(
data_objects = 'should use data directly. Using TealDatasetConnector and TealDataset is deprecated.
Find more information on https://github.com/insightsengineering/teal/discussions/945'
Expand Down
30 changes: 20 additions & 10 deletions R/utils-get_code_dependency.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,27 @@ fix_shifted_comments <- function(calls) {
#' @keywords internal
#' @noRd
fix_arrows <- function(calls) {
lapply(
calls,
function(call) {
call[call$token == "SYMBOL_FUNCTION_CALL" & call$text == "`<-`", c("token", "text")] <- c("LEFT_ASSIGN", "<-")
call[call$token == "SYMBOL_FUNCTION_CALL" & call$text == "`->`", c("token", "text")] <- c("RIGHT_ASSIGN", "->")
call[call$token == "SYMBOL_FUNCTION_CALL" & call$text == "`<<-`", c("token", "text")] <- c("LEFT_ASSIGN", "<-")
call[call$token == "SYMBOL_FUNCTION_CALL" & call$text == "`->>`", c("token", "text")] <- c("RIGHT_ASSIGN", "->")
call[call$token == "SYMBOL_FUNCTION_CALL" & call$text == "`=`", c("token", "text")] <- c("LEFT_ASSIGN", "<-")
call
}
checkmate::assert_list(calls)
lapply(calls, function(call) {
sym_fun <- call$token == "SYMBOL_FUNCTION_CALL"
call[sym_fun, ] <- sub_arrows(call[sym_fun, ])
call
})
}

#' Execution of assignment operator substitutions for a call.
#' @keywords internal
#' @noRd
sub_arrows <- function(call) {
checkmate::assert_data_frame(call)
map <- data.frame(
row.names = c("`<-`", "`<<-`", "`=`"),
token = rep("LEFT_ASSIGN", 3),
text = rep("<-", 3)
)
sub_ids <- call$text %in% rownames(map)
call[sub_ids, c("token", "text")] <- map[call$text[sub_ids], ]
call
}

# code_graph ----
Expand Down
18 changes: 0 additions & 18 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,2 @@
.onLoad <- function(libname, pkgname) {
# expose default CDISC dataset names
# copy from excel file
default_cdisc_keys <- yaml::yaml.load_file(
system.file("cdisc_datasets/cdisc_datasets.yaml", package = "teal.data")
)
assign("default_cdisc_keys", default_cdisc_keys, envir = parent.env(environment()))

# update default_cdisc_join_keys
assign(
"default_cdisc_join_keys",
build_cdisc_join_keys(default_cdisc_keys),
envir = parent.env(environment())
)

invisible()
}

# use non-exported function from teal.code
lang2calls <- getFromNamespace("lang2calls", "teal.code")
File renamed without changes.
22 changes: 22 additions & 0 deletions data-raw/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,25 @@ usethis::use_data(rADTTE)

rADVS <- synthetic_cdisc_data("latest")$advs # nolint: object_name_linter.
usethis::use_data(rADVS)

## Code to prepare default CDISC datasets for `teal.data`
default_cdisc_keys <- yaml::yaml.load_file(file.path("data-raw", "cdisc_datasets.yaml"))

default_cdisc_join_keys <- teal.data::join_keys()
for (name in names(default_cdisc_keys)) {
# Set default primary keys
keys_list <- default_cdisc_keys[[name]]

if (!is.null(keys_list[["primary"]])) {
default_cdisc_join_keys[[name]][[name]] <- keys_list[["primary"]]
}

if (!is.null(keys_list[["parent"]])) {
if (!is.null(keys_list[["foreign"]])) {
default_cdisc_join_keys[[name]][[keys_list[["parent"]]]] <- keys_list[["foreign"]]
}
teal.data::parents(default_cdisc_join_keys)[[name]] <- keys_list[["parent"]]
}
}

usethis::use_data(default_cdisc_join_keys)
Binary file added data/default_cdisc_join_keys.rda
Binary file not shown.
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ CDISC
Forkers
Getter
Hoffmann
ORCID
Reproducibility
formatters
funder
Expand Down
17 changes: 0 additions & 17 deletions inst/js/custom.js

This file was deleted.

16 changes: 0 additions & 16 deletions man/build_cdisc_join_keys.Rd

This file was deleted.

7 changes: 3 additions & 4 deletions man/cdisc_data.Rd

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

2 changes: 1 addition & 1 deletion man/col_labels.Rd

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

14 changes: 12 additions & 2 deletions man/default_cdisc_join_keys.Rd

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

6 changes: 3 additions & 3 deletions man/teal.data-package.Rd

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

Loading

0 comments on commit 2d9fc71

Please sign in to comment.