Skip to content

Commit

Permalink
658 remove var labels@pre release@main (#673)
Browse files Browse the repository at this point in the history
Closes #658 

All instances of `var_labels` were replaced with
`teal.data::col_labels`.
Source for `var_labels` was removed.
  • Loading branch information
chlebowa authored Feb 23, 2024
1 parent 2d89cfb commit 2ac9a4d
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 78 deletions.
2 changes: 1 addition & 1 deletion R/tm_a_pca.R
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
response[[i]]$select$multiple <- FALSE
response[[i]]$select$always_selected <- NULL
response[[i]]$select$selected <- NULL
response[[i]]$select$choices <- var_labels(isolate(data())[[response[[i]]$dataname]])
response[[i]]$select$choices <- teal.data::col_labels(isolate(data())[[response[[i]]$dataname]])
response[[i]]$select$choices <- setdiff(
response[[i]]$select$choices,
unlist(teal.data::join_keys(isolate(data()))[[response[[i]]$dataname]])
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
48 changes: 0 additions & 48 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -272,54 +272,6 @@ include_css_files <- function(pattern = "*") {
}


#' 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 2ac9a4d

Please sign in to comment.