Skip to content

Commit

Permalink
removes labelled class
Browse files Browse the repository at this point in the history
  • Loading branch information
DanChaltiel committed Nov 25, 2021
1 parent 122e388 commit 66bcff9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
7 changes: 2 additions & 5 deletions R/labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ set_label = function(x, value, object=FALSE){
return(x)
}
attr(x, "label") = value
if (!"labelled" %in% class(x)) {
class(x) = c("labelled", class(x))
}
return(x)
}

Expand Down Expand Up @@ -125,8 +122,8 @@ copy_label_from = function(x, from){
#' @aliases remove_label
#' @seealso [get_label], [set_label], [import_labels], [expss::unlab]
#' @examples
#' mtcars2 %>% remove_labels %>% crosstable(1:2) #no labels
#' mtcars2$hp %>% remove_labels %>% get_label #numeric
#' mtcars2 %>% remove_labels %>% crosstable(mpg) #no label
#' mtcars2$hp %>% remove_labels %>% get_label() #NULL
remove_labels = function(x){
if (is.null(x))
return(x)
Expand Down
3 changes: 0 additions & 3 deletions tests/testthat/test-labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ test_that("Removing labels", {
expect_type(x, "double")
expect_type(x2, "double")

expect_s3_class(x, c("labelled", "numeric"))
expect_s3_class(x2, NA)

#limit case
expect_null(remove_label(NULL))
})
Expand Down

0 comments on commit 66bcff9

Please sign in to comment.