Skip to content

Commit

Permalink
Merge branch 'main' into 66-repel_label@main
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo authored Feb 27, 2024
2 parents 5503776 + b2da3d3 commit ce39fb7
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 80 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: teal.modules.general
Title: General Modules to Add to a `teal` Application
Version: 0.2.16.9024
Version: 0.2.16.9025
Date: 2024-02-27
Authors@R: c(
person("Dawid", "Kaledkowski", , "dawid.kaledkowski@roche.com", role = c("aut", "cre")),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# teal.modules.general 0.2.16.9024
# teal.modules.general 0.2.16.9025

### Enhancements

Expand Down
2 changes: 1 addition & 1 deletion R/tm_missing_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, par
},
env = list(
new_col_name = new_col_name,
column_labels_value = c(var_labels(data_r())[selected_vars()],
column_labels_value = c(teal.data::col_labels(data_r())[selected_vars()],
new_col_name = new_col_name
)
)
Expand Down
2 changes: 1 addition & 1 deletion R/tm_variable_browser.R
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ get_plotted_data <- function(input, plot_var, data) {
varname <- plot_var$variable[[dataset_name]]
df <- data()[[dataset_name]]

var_description <- var_labels(df)[[varname]]
var_description <- teal.data::col_labels(df)[[varname]]
list(data = df[[varname]], var_description = var_description)
}

Expand Down
49 changes: 0 additions & 49 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -287,55 +287,6 @@ include_css_files <- function(pattern = "*") {
return(shiny::singleton(shiny::tags$head(lapply(css_files, shiny::includeCSS))))
}


#' Get Label Attributes of Variables in a \code{data.frame}
#'
#' Variable labels can be stored as a \code{label} attribute for each variable.
#' This functions returns a named character vector with the variable labels
#' (empty sting if not specified)
#'
#' @param x a \code{data.frame} object
#' @param fill boolean in case the \code{label} attribute does not exist if
#' \code{TRUE} the variable names is returned, otherwise \code{NA}
#'
#' @return a named character vector with the variable labels, the names
#' correspond to the variable names
#'
#' @note the `formatters` package is the source of the function.
#'
#' @keywords internal
var_labels <- function(x, fill = FALSE) {
stopifnot(is.data.frame(x))
if (NCOL(x) == 0) {
return(character())
}

y <- Map(function(col, colname) {
label <- attr(col, "label")

if (is.null(label)) {
if (fill) {
colname
} else {
NA_character_
}
} else {
if (!is.character(label) && !(length(label) == 1)) {
stop("label for variable ", colname, "is not a character string")
}
as.vector(label)
}
}, x, colnames(x))

labels <- unlist(y, recursive = FALSE, use.names = TRUE)

if (!is.character(labels)) {
stop("label extraction failed")
}

labels
}

#' Get a string with java-script code checking if the specific tab is clicked
#' @description will be the input for `shiny::conditionalPanel()`
#' @param id `character(1)` the id of the tab panel with tabs.
Expand Down
27 changes: 0 additions & 27 deletions man/var_labels.Rd

This file was deleted.

0 comments on commit ce39fb7

Please sign in to comment.