Skip to content

Commit

Permalink
allow NA for set_label_attribute()
Browse files Browse the repository at this point in the history
  • Loading branch information
larmarange committed Jan 7, 2025
1 parent 494a22a commit ee901d0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/var_label.R
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ get_label_attribute <- function(x) {
#' @rdname var_label
#' @export
set_label_attribute <- function(x, value) {
check_string(value, allow_null = TRUE)
check_string(value, allow_null = TRUE, allow_na = TRUE)
attr(x, "label") <- value
x
}
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-labelled.r
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test_that("var_label works properly", {
var_label(x) <- NULL
expect_null(attr(x, "label"))
expect_null(var_label(x))
expect_no_error(var_label(x) <- NA_character_)

x <- 1:3
x <- set_variable_labels(x, "value")
Expand Down

0 comments on commit ee901d0

Please sign in to comment.