Skip to content

Commit

Permalink
Merge branch 'tabyl-label' of https://github.com/olivroy/janitor into…
Browse files Browse the repository at this point in the history
… tabyl-label
  • Loading branch information
olivroy committed May 23, 2024
2 parents 4ddb384 + 8f0e33d commit 89cdb72
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/tabyl.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ tabyl.default <- function(dat, show_na = TRUE, show_missing_levels = TRUE, ...)
} else {
var_name <- names(dat)
}

# useful error message if input vector doesn't exist
if (is.null(dat)) {
stop(paste0("object ", var_name, " not found"))
Expand All @@ -74,12 +74,12 @@ tabyl.default <- function(dat, show_na = TRUE, show_missing_levels = TRUE, ...)
if (length(var_name) > 1) {
var_name <- paste(var_name, collapse = "")
}

# Try to retrieve label
if (is.data.frame(dat)) {
var_label <- attr(dat[, var_name], "label", exact = TRUE) %||% var_name
} else {
var_label <- attr(dat, "label", exact = TRUE) %||% var_name
var_label <- attr(dat, "label", exact = TRUE) %||% var_name
}

# if show_na is not length-1 logical, error helpfully (#377)
Expand Down

0 comments on commit 89cdb72

Please sign in to comment.