From c8a448ca80925772769b02569c2a7809d5953c9e Mon Sep 17 00:00:00 2001 From: m7pr Date: Thu, 18 Jan 2024 11:54:34 +0100 Subject: [PATCH 1/6] test for ; case --- tests/testthat/test-get_code.R | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/testthat/test-get_code.R b/tests/testthat/test-get_code.R index 32054ba58..09360c3b8 100644 --- a/tests/testthat/test-get_code.R +++ b/tests/testthat/test-get_code.R @@ -166,6 +166,17 @@ testthat::test_that("get_code returns result of length 1 for non-empty input", { testthat::expect_length(get_code(tdata1, deparse = TRUE), 1) }) +testthat::test_that("get_code does not break if code is separated by ;", { + code <- c( + "a <- 1;a <- a + 1" + ) + tdata <- eval_code(teal_data(), code) + testthat::expect_identical( + get_code(tdata, datanames = "a"), + gsub(";", "\n", code, fixed = TRUE) + ) +}) + # assign ---------------------------------------------------------------------------------------------------------- From 7106fa8f1e16c89b52b769de8db436afe27e92da Mon Sep 17 00:00:00 2001 From: Dony Unardi Date: Wed, 31 Jan 2024 21:50:12 -0800 Subject: [PATCH 2/6] [skip vbump] upversion to 0.4.0 (#280) Related with #226 --- DESCRIPTION | 21 +++++------ NAMESPACE | 1 - NEWS.md | 2 +- R/cdisc_data.R | 2 +- R/data.R | 10 +++++ R/default_cdisc_join_keys.R | 35 ------------------ R/deprecated.R | 4 +- R/teal_data.R | 19 +++++++--- R/zzz.R | 18 --------- .../cdisc_datasets.yaml | 0 data-raw/data.R | 22 +++++++++++ data/default_cdisc_join_keys.rda | Bin 0 -> 634 bytes inst/WORDLIST | 1 + inst/js/custom.js | 17 --------- man/build_cdisc_join_keys.Rd | 16 -------- man/cdisc_data.Rd | 7 ++-- man/col_labels.Rd | 2 +- man/default_cdisc_join_keys.Rd | 12 +++++- man/teal.data-package.Rd | 6 +-- man/teal_data.Rd | 12 ++---- tests/testthat/test-cdisc_data.R | 11 +++--- 21 files changed, 88 insertions(+), 130 deletions(-) delete mode 100644 R/default_cdisc_join_keys.R rename {inst/cdisc_datasets => data-raw}/cdisc_datasets.yaml (100%) create mode 100644 data/default_cdisc_join_keys.rda delete mode 100644 inst/js/custom.js delete mode 100644 man/build_cdisc_join_keys.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 62c577c7a..fe30f1b1a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,13 +1,14 @@ Type: Package Package: teal.data Title: Data Model for 'teal' Applications -Version: 0.3.0.9042 +Version: 0.4.0 Date: 2024-01-24 Authors@R: c( - person("Dawid", "Kaledkowski", , "dawid.kaledkowski@roche.com", role = c("aut", "cre")), - person("Aleksander", "Chlebowski", , "aleksander.chlebowski@contractors.roche.com", role = "aut"), + person("Dawid", "Kaledkowski", , "dawid.kaledkowski@roche.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-9533-457X")), + person("Aleksander", "Chlebowski", , "aleksander.chlebowski@contractors.roche.com", role = "aut", + comment = c(ORCID = "0000-0001-5018-6294")), person("Marcin", "Kosinski", , "marcin.kosinski.mk1@roche.com", role = "aut"), - person("Andre", "Verissimo", , "andre.verissimo@roche.com", role = "aut"), + person("Andre", "Verissimo", , "andre.verissimo@roche.com", role = "aut", comment = c(ORCID = "0000-0002-2212-339X")), person("Pawel", "Rucki", , "pawel.rucki@roche.com", role = "aut"), person("Mahmoud", "Hallal", , "mahmoud.hallal@roche.com", role = "aut"), person("Nikolas", "Burkoff", role = "aut"), @@ -18,8 +19,8 @@ Authors@R: c( person("Dony", "Unardi", , "unardid@gene.com", 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/ @@ -33,8 +34,7 @@ Imports: methods, rlang (>= 1.1.0), stats, - utils, - yaml + utils Suggests: knitr (>= 1.42), rmarkdown (>= 2.19), @@ -44,7 +44,7 @@ VignetteBuilder: RdMacros: lifecycle Config/Needs/verdepcheck: mllg/checkmate, r-lib/lifecycle, r-lib/rlang, - yaml=vubiostat/r-yaml, yihui/knitr, rstudio/rmarkdown, + yihui/knitr, rstudio/rmarkdown, insightsengineering/teal.code, r-lib/testthat Config/Needs/website: insightsengineering/nesttemplate Encoding: UTF-8 @@ -52,10 +52,9 @@ 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' diff --git a/NAMESPACE b/NAMESPACE index 8b39873a1..71db8957b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/NEWS.md b/NEWS.md index dd39b9f1f..8dc3f9939 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.data 0.3.0.9042 +# teal.data 0.4.0 ### Enhancements diff --git a/R/cdisc_data.R b/R/cdisc_data.R index 331ef7452..807e3bdd3 100644 --- a/R/cdisc_data.R +++ b/R/cdisc_data.R @@ -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) } diff --git a/R/data.R b/R/data.R index 1ade4541f..88d6abea5 100644 --- a/R/data.R +++ b/R/data.R @@ -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" diff --git a/R/default_cdisc_join_keys.R b/R/default_cdisc_join_keys.R deleted file mode 100644 index a1e0d82d4..000000000 --- a/R/default_cdisc_join_keys.R +++ /dev/null @@ -1,35 +0,0 @@ -#' 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 -#' @docType data -#' @export -NULL - -#' Helper method to build `default_cdisc_join_keys` -#' @param default_cdisc_keys (`list`) default definition of primary and foreign -#' keys for `CDISC` datasets -#' -#' @keywords internal -build_cdisc_join_keys <- function(default_cdisc_keys) { - checkmate::assert_list(default_cdisc_keys, types = "list") - - jk <- 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"]])) { - jk[[name]][[name]] <- keys_list[["primary"]] - } - - if (!is.null(keys_list[["parent"]])) { - if (!is.null(keys_list[["foreign"]])) { - jk[[name]][[keys_list[["parent"]]]] <- keys_list[["foreign"]] - } - parents(jk)[[name]] <- keys_list[["parent"]] - } - } - jk -} diff --git a/R/deprecated.R b/R/deprecated.R index ad295f4a8..d4b3e9e93 100644 --- a/R/deprecated.R +++ b/R/deprecated.R @@ -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 ) @@ -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)") diff --git a/R/teal_data.R b/R/teal_data.R index 5e37ba35a..70a2d472f 100644 --- a/R/teal_data.R +++ b/R/teal_data.R @@ -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. #' @@ -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, @@ -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' diff --git a/R/zzz.R b/R/zzz.R index 97652d917..b1dfb9432 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -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") diff --git a/inst/cdisc_datasets/cdisc_datasets.yaml b/data-raw/cdisc_datasets.yaml similarity index 100% rename from inst/cdisc_datasets/cdisc_datasets.yaml rename to data-raw/cdisc_datasets.yaml diff --git a/data-raw/data.R b/data-raw/data.R index 395da5c8b..4a81b0da6 100644 --- a/data-raw/data.R +++ b/data-raw/data.R @@ -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) diff --git a/data/default_cdisc_join_keys.rda b/data/default_cdisc_join_keys.rda new file mode 100644 index 0000000000000000000000000000000000000000..bee6bd0324b6ff3a7dff1ff07644251c064b2cb4 GIT binary patch literal 634 zcmV-=0)_oTT4*^jL0KkKS;D83aR3gdZ-D>sSb#nNKlguNuRq=(00GbgUUcYa06H3} zrkZkY=ht000^Q00003m;e9( z000000Hr9J5E>IAdW}6yfY9`S01kv|bt6errxCxVRM5a-iZIHc#v=^s@`wB%)+o%A zjByG-xLQjnXb=p5GC=~C+Cym{sHW0OpF%qki0ao`M&+&+?fdoAH6s~t=9qJ4xZksQ zLgSGpy?L*)$Jb_)WN|qtj&d?c!3C6n329^REF%r0_ zRw^tp8A#^RO0~tV0aAw?4YZV2nnGg%p`ZZ>00bedCfZL!xrY50dCqekMi^l1FgX}B zF-KvEh8r3;G&vq+d7<&G?cp7)&B}KjZU%>(I}D1$ z1}TaRSbc}uqUmE67{S53(9zuE$x`2KW@EjJ7X!fPAyL(sct>#FJh&K%BK}P zRV<~;D>E|9=cMU(9gP^pbrrGJ*|IN%R{#J2 literal 0 HcmV?d00001 diff --git a/inst/WORDLIST b/inst/WORDLIST index 695d2028a..a4662949b 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -5,6 +5,7 @@ Reproducibility formatters funder getter +ORCID pre repo reproducibility diff --git a/inst/js/custom.js b/inst/js/custom.js deleted file mode 100644 index d124a26be..000000000 --- a/inst/js/custom.js +++ /dev/null @@ -1,17 +0,0 @@ -// allow a button to be pressed by pressing the enter key see -// https://github.com/daattali/advanced-shiny/blob/master/proxy-click/app.R -$(function () { - var $els = $("[data-proxy-click]"); - $.each( - $els, - function (idx, el) { - var $el = $(el); - var $proxy = $("#" + $el.data("proxyClick")); - $el.keydown(function (e) { - if (e.keyCode == 13) { - $proxy.click(); - } - }); - } - ); -}); diff --git a/man/build_cdisc_join_keys.Rd b/man/build_cdisc_join_keys.Rd deleted file mode 100644 index 973ab213c..000000000 --- a/man/build_cdisc_join_keys.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/default_cdisc_join_keys.R -\name{build_cdisc_join_keys} -\alias{build_cdisc_join_keys} -\title{Helper method to build \code{default_cdisc_join_keys}} -\usage{ -build_cdisc_join_keys(default_cdisc_keys) -} -\arguments{ -\item{default_cdisc_keys}{(\code{list}) default definition of primary and foreign -keys for \code{CDISC} datasets} -} -\description{ -Helper method to build \code{default_cdisc_join_keys} -} -\keyword{internal} diff --git a/man/cdisc_data.Rd b/man/cdisc_data.Rd index cecd579eb..2c356d90a 100644 --- a/man/cdisc_data.Rd +++ b/man/cdisc_data.Rd @@ -8,7 +8,7 @@ cdisc_data( ..., join_keys = teal.data::default_cdisc_join_keys[names(rlang::list2(...))], code = character(0), - check = FALSE + check ) } \arguments{ @@ -23,9 +23,8 @@ For ADAM datasets it would be automatically derived.} \item{code}{(\code{character}, \code{language}) optional code to reproduce the datasets provided in \code{...}. Note this code is not executed and the \code{teal_data} may not be reproducible} -\item{check}{(\code{logical}) reproducibility check - whether to perform a check that the pre-processing -code included in the object definitions actually produces those objects. -If \code{check} is true and preprocessing code is empty an error will be thrown.} +\item{check}{(\code{logical}) \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +Use \code{\link[=verify]{verify()}} to verify code reproducibility .} } \value{ A \code{teal_data} object. diff --git a/man/col_labels.Rd b/man/col_labels.Rd index 7e2467d60..708f676be 100644 --- a/man/col_labels.Rd +++ b/man/col_labels.Rd @@ -49,7 +49,7 @@ These functions get or set this attribute, either on all (\code{col_labels}) or \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} In previous versions of \code{teal.data} labels were managed with \code{get_labels()}. -This function is deprecated as of \verb{0.3.1}, use \code{col_labels} instead. +This function is deprecated as of \verb{0.4.0}, use \code{col_labels} instead. } \examples{ x <- iris diff --git a/man/default_cdisc_join_keys.Rd b/man/default_cdisc_join_keys.Rd index f0c53ebd1..266dd9d9c 100644 --- a/man/default_cdisc_join_keys.Rd +++ b/man/default_cdisc_join_keys.Rd @@ -1,9 +1,19 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/default_cdisc_join_keys.R +% Please edit documentation in R/data.R \docType{data} \name{default_cdisc_join_keys} \alias{default_cdisc_join_keys} \title{List containing default joining keys for \code{CDISC} datasets} +\format{ +An object of class \code{join_keys} (inherits from \code{list}) of length 19. +} +\source{ +internal +} +\usage{ +default_cdisc_join_keys +} \description{ This data object is created at loading time from \code{cdisc_datasets/cdisc_datasets.yaml}. } +\keyword{datasets} diff --git a/man/teal.data-package.Rd b/man/teal.data-package.Rd index 5aa95a20e..8dce91496 100644 --- a/man/teal.data-package.Rd +++ b/man/teal.data-package.Rd @@ -21,13 +21,13 @@ Useful links: } \author{ -\strong{Maintainer}: Dawid Kaledkowski \email{dawid.kaledkowski@roche.com} +\strong{Maintainer}: Dawid Kaledkowski \email{dawid.kaledkowski@roche.com} (\href{https://orcid.org/0000-0001-9533-457X}{ORCID}) Authors: \itemize{ - \item Aleksander Chlebowski \email{aleksander.chlebowski@contractors.roche.com} + \item Aleksander Chlebowski \email{aleksander.chlebowski@contractors.roche.com} (\href{https://orcid.org/0000-0001-5018-6294}{ORCID}) \item Marcin Kosinski \email{marcin.kosinski.mk1@roche.com} - \item Andre Verissimo \email{andre.verissimo@roche.com} + \item Andre Verissimo \email{andre.verissimo@roche.com} (\href{https://orcid.org/0000-0002-2212-339X}{ORCID}) \item Pawel Rucki \email{pawel.rucki@roche.com} \item Mahmoud Hallal \email{mahmoud.hallal@roche.com} \item Nikolas Burkoff diff --git a/man/teal_data.Rd b/man/teal_data.Rd index a8b6b6008..5676cef15 100644 --- a/man/teal_data.Rd +++ b/man/teal_data.Rd @@ -4,12 +4,7 @@ \alias{teal_data} \title{Comprehensive data integration function for \code{teal} applications} \usage{ -teal_data( - ..., - join_keys = teal.data::join_keys(), - code = character(0), - check = FALSE -) +teal_data(..., join_keys = teal.data::join_keys(), code = character(0), check) } \arguments{ \item{...}{any number of objects (presumably data objects) provided as \code{name = value} pairs.} @@ -22,9 +17,8 @@ If empty then no joins between pairs of objects.} \item{code}{(\code{character}, \code{language}) optional code to reproduce the datasets provided in \code{...}. Note this code is not executed and the \code{teal_data} may not be reproducible} -\item{check}{(\code{logical}) reproducibility check - whether to perform a check that the pre-processing -code included in the object definitions actually produces those objects. -If \code{check} is true and preprocessing code is empty an error will be thrown.} +\item{check}{(\code{logical}) \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +Use \code{\link[=verify]{verify()}} to verify code reproducibility .} } \value{ A \code{teal_data} object. diff --git a/tests/testthat/test-cdisc_data.R b/tests/testthat/test-cdisc_data.R index bccb68c07..403a5497c 100644 --- a/tests/testthat/test-cdisc_data.R +++ b/tests/testthat/test-cdisc_data.R @@ -1,7 +1,8 @@ -testthat::test_that("cdisc_data returns teal_data object for objects different than old api", { - adsl_raw <- as.data.frame(as.list(stats::setNames(nm = default_cdisc_join_keys["ADSL", "ADSL"]))) - testthat::expect_s4_class( - teal_data(adsl = adsl_raw, check = TRUE), - "teal_data" +testthat::test_that("cdisc_data returns teal_data object with default join_keys for given dataset", { + data <- cdisc_data(ADSL = data.frame()) + testthat::expect_s4_class(data, "teal_data") + testthat::expect_identical( + join_keys(data), + default_cdisc_join_keys["ADSL"] ) }) From d866bb153dccb7e4a7121fe73d312fbeb454c25d Mon Sep 17 00:00:00 2001 From: donyunardi Date: Thu, 1 Feb 2024 05:52:05 +0000 Subject: [PATCH 3/6] [skip actions] Update WORDLIST --- inst/WORDLIST | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/WORDLIST b/inst/WORDLIST index a4662949b..b84a59865 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,11 +1,11 @@ Forkers Getter Hoffmann +ORCID Reproducibility formatters funder getter -ORCID pre repo reproducibility From d857d98074e4a4ad2c25c7ba14ff67ccdab59e62 Mon Sep 17 00:00:00 2001 From: insights-engineering-bot Date: Thu, 1 Feb 2024 05:52:33 +0000 Subject: [PATCH 4/6] [skip actions] Bump version to 0.4.0.9000 --- DESCRIPTION | 18 ++++++++++-------- NEWS.md | 2 ++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index fe30f1b1a..1e892b1a4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,14 +1,16 @@ Type: Package Package: teal.data Title: Data Model for 'teal' Applications -Version: 0.4.0 -Date: 2024-01-24 +Version: 0.4.0.9000 +Date: 2024-02-01 Authors@R: c( - person("Dawid", "Kaledkowski", , "dawid.kaledkowski@roche.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-9533-457X")), + person("Dawid", "Kaledkowski", , "dawid.kaledkowski@roche.com", role = c("aut", "cre"), + comment = c(ORCID = "0000-0001-9533-457X")), person("Aleksander", "Chlebowski", , "aleksander.chlebowski@contractors.roche.com", role = "aut", comment = c(ORCID = "0000-0001-5018-6294")), person("Marcin", "Kosinski", , "marcin.kosinski.mk1@roche.com", role = "aut"), - person("Andre", "Verissimo", , "andre.verissimo@roche.com", role = "aut", comment = c(ORCID = "0000-0002-2212-339X")), + person("Andre", "Verissimo", , "andre.verissimo@roche.com", role = "aut", + comment = c(ORCID = "0000-0002-2212-339X")), person("Pawel", "Rucki", , "pawel.rucki@roche.com", role = "aut"), person("Mahmoud", "Hallal", , "mahmoud.hallal@roche.com", role = "aut"), person("Nikolas", "Burkoff", role = "aut"), @@ -19,8 +21,8 @@ Authors@R: c( person("Dony", "Unardi", , "unardid@gene.com", role = "rev"), person("F. Hoffmann-La Roche AG", role = c("cph", "fnd")) ) -Description: Provides a 'teal_data' class as a unified data model for 'teal' applications - focusing on reproducibility and relational data. +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/ @@ -44,8 +46,8 @@ VignetteBuilder: RdMacros: lifecycle Config/Needs/verdepcheck: mllg/checkmate, r-lib/lifecycle, r-lib/rlang, - 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 diff --git a/NEWS.md b/NEWS.md index 8dc3f9939..5909f24e2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,5 @@ +# teal.data 0.4.0.9000 + # teal.data 0.4.0 ### Enhancements From 321ee730173512271f23b3d046b5d2c8eb5abd76 Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Fri, 2 Feb 2024 16:11:19 +0100 Subject: [PATCH 5/6] 277 improve `fix_arrows` (#287) Close #277 --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- R/utils-get_code_dependency.R | 30 ++++++++++++++++++++---------- tests/testthat/test-get_code.R | 6 ++++++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/R/utils-get_code_dependency.R b/R/utils-get_code_dependency.R index 98fd8926c..cff84e816 100644 --- a/R/utils-get_code_dependency.R +++ b/R/utils-get_code_dependency.R @@ -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 ---- diff --git a/tests/testthat/test-get_code.R b/tests/testthat/test-get_code.R index 85788da87..0644d1a51 100644 --- a/tests/testthat/test-get_code.R +++ b/tests/testthat/test-get_code.R @@ -253,13 +253,19 @@ testthat::test_that("detects function usage of the assignment operator", { "x <- 1", "`<-`(y,x)" ) + code2 <- "`<-`(y, `<-`(x, 2))" tdata <- eval_code(teal_data(), code) + tdata2 <- eval_code(teal_data(), code2) testthat::expect_identical( get_code(tdata, datanames = "y"), paste(c(code[1], "y <- x"), collapse = "\n") ) + testthat::expect_identical( + get_code(tdata2, datanames = "y"), + "y <- x <- 2" + ) }) From 602da85076a25103dd4a59d626fd82ebdad9ec8c Mon Sep 17 00:00:00 2001 From: m7pr Date: Fri, 2 Feb 2024 15:12:17 +0000 Subject: [PATCH 6/6] [skip actions] Bump version to 0.4.0.9001 --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1e892b1a4..dd6cfaf56 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: teal.data Title: Data Model for 'teal' Applications -Version: 0.4.0.9000 -Date: 2024-02-01 +Version: 0.4.0.9001 +Date: 2024-02-02 Authors@R: c( person("Dawid", "Kaledkowski", , "dawid.kaledkowski@roche.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-9533-457X")), diff --git a/NEWS.md b/NEWS.md index 5909f24e2..321564dca 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.data 0.4.0.9000 +# teal.data 0.4.0.9001 # teal.data 0.4.0