Skip to content

Commit

Permalink
Style code (GHA)
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed May 23, 2024
1 parent a0f5c59 commit 8f0e33d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 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
2 changes: 1 addition & 1 deletion tests/testthat/test-tabyl.R
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ test_that("tabyl works with label attributes (#394)", {
tab <- tabyl(mt_label, cyl)
expect_named(tab, c("Number of cyl", "n", "percent"))

tab2 <- tabyl(mt_label, cyl, am)
tab2 <- tabyl(mt_label, cyl, am)
expect_named(tab2, c("Number of cyl", "0", "1"))
})

Expand Down

0 comments on commit 8f0e33d

Please sign in to comment.