Skip to content

Commit

Permalink
147 remove formatters (#148)
Browse files Browse the repository at this point in the history
Closes #147

---------

Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com>
  • Loading branch information
m7pr and chlebowa authored Jul 31, 2023
1 parent 9f7c7f8 commit 71a3147
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 18 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Depends:
Imports:
checkmate,
dplyr,
formatters (>= 0.3.1),
lifecycle,
logger (>= 0.2.0),
methods,
Expand Down
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,5 @@ export(split_by_sep)
export(value_choices)
export(variable_choices)
import(shiny)
importFrom(formatters,var_labels)
importFrom(formatters,var_relabel)
importFrom(lifecycle,badge)
importFrom(magrittr,"%>%")
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

* Removed `scda` package dependency from examples.
* Deprecated `data_merge_module()` and `data_merge_srv()`.
* The `get_relabel_call` function now returns a call to `teal.data::col_relabel` instead of one to `formatters::var_relabel`.

# teal.transform 0.2.0

Expand Down
8 changes: 4 additions & 4 deletions R/choices_labeled.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
#'
#' ADSL <- teal.transform::rADSL
#' ADTTE <- teal.transform::rADTTE
#' choices1 <- choices_labeled(names(ADSL), formatters::var_labels(ADSL, fill = FALSE))
#' choices1 <- choices_labeled(names(ADSL), teal.data::col_labels(ADSL, fill = FALSE))
#' choices2 <- choices_labeled(ADTTE$PARAMCD, ADTTE$PARAM)
#' # if only a subset of variables are needed, use subset argument
#' choices3 <- choices_labeled(
#' names(ADSL),
#' formatters::var_labels(ADSL, fill = FALSE),
#' teal.data::col_labels(ADSL, fill = FALSE),
#' subset = c("ARMCD", "ARM")
#' )
#' \dontrun{
Expand Down Expand Up @@ -221,14 +221,14 @@ variable_choices.data.frame <- function(data, subset = NULL, fill = TRUE, key =
res <- if ("" %in% subset) {
choices_labeled(
choices = c("", names(data)),
labels = c("", unname(formatters::var_labels(data, fill = fill))),
labels = c("", unname(teal.data::col_labels(data, fill = fill))),
subset = subset,
types = c("", var_types)
)
} else {
choices_labeled(
choices = names(data),
labels = unname(formatters::var_labels(data, fill = fill)),
labels = unname(teal.data::col_labels(data, fill = fill)),
subset = subset,
types = var_types
)
Expand Down
4 changes: 2 additions & 2 deletions R/get_merge_call.R
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ get_anl_relabel_call <- function(columns_source, datasets, anl_name = "ANL") {
}

data_used <- datasets[[attr(selector, "dataname")]]
labels <- formatters::var_labels(data_used(), fill = FALSE)
labels <- teal.data::col_labels(data_used(), fill = FALSE)
column_labels <- labels[intersect(colnames(data_used()), column_names)]

# NULL for no labels at all, character(0) for no labels for a given columns
Expand Down Expand Up @@ -432,7 +432,7 @@ get_relabel_call <- function(labels) {
return(
as.call(
append(
quote(formatters::var_relabel),
quote(teal.data::col_relabel),
labels
)
)
Expand Down
1 change: 0 additions & 1 deletion R/teal.transform-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@

#' @import shiny
#' @importFrom magrittr %>%
#' @importFrom formatters var_relabel var_labels
#' @importFrom lifecycle badge
NULL
4 changes: 2 additions & 2 deletions man/choices_labeled.Rd

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

3 changes: 0 additions & 3 deletions staged_dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ upstream_repos:
insightsengineering/teal.slice:
repo: insightsengineering/teal.slice
host: https://github.com
insightsengineering/formatters:
repo: insightsengineering/formatters
host: https://github.com
downstream_repos:
insightsengineering/teal:
repo: insightsengineering/teal
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-merge_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ testthat::test_that("get_relabel_call", {
as.call(
parse(
text =
'formatters::var_relabel(
'teal.data::col_relabel(
AGE = "Age",
SEX = "Sex",
AVAL = "Continuous Variable",
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-variable_choices.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ test_that("Can create variable_choices with datasets with no or missing labels",

# one missing label
missing_one_label_data <- example_data
formatters::var_labels(missing_one_label_data) <- c(as.character(NA), "Label")
teal.data::col_labels(missing_one_label_data) <- c(as.character(NA), "Label")
choice_2 <- variable_choices(missing_one_label_data, fill = FALSE)
expect_equal(names(choice_2), c("USUBJID: Label Missing", "STUDYID: Label"))

# all missing label
missing_two_label_data <- example_data
formatters::var_labels(missing_two_label_data) <- c(as.character(NA), as.character(NA))
teal.data::col_labels(missing_two_label_data) <- c(as.character(NA), as.character(NA))
choice_2 <- variable_choices(missing_two_label_data, fill = FALSE)
expect_equal(names(choice_2), c("USUBJID: Label Missing", "STUDYID: Label Missing"))
})
Expand Down

0 comments on commit 71a3147

Please sign in to comment.