Skip to content

Commit

Permalink
update to pass GH checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ayogasekaram committed Jun 5, 2024
1 parent 6f03d24 commit 4554691
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ Imports:
tidyr
Suggests:
testthat (>= 3.2.0),
usethis
usethis,
forcats,
stringr
Config/testthat/edition: 3
Config/testthat/parallel: true
Encoding: UTF-8
Expand Down
11 changes: 7 additions & 4 deletions R/standalone-forcats.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ fct_rev <- function(f) {
)
}


fct_expand <- function(f, ..., after = Inf) {
f <- levels(f) |> append(values = c(...), after = after)
old_levels <- levels(f)
new_levels <- as.character(...)
new_levels <- append(old_levels, setdiff(new_levels, old_levels),
after = after)
f <- factor(f, levels = unique(new_levels))
return(f)
}

Expand All @@ -54,15 +59,13 @@ fct_na_value_to_level <- function(f, level = NA) {
# Add the new level to the factor's levels
levels(f) <- c(levels(f), level_char)
}
inds <- is.na(f)
inds <- is.na(f)
if (any(inds)) {
f[inds] <- level_char
}

return(factor(f, levels = levels(f)))
}



# nocov end
# styler: on

0 comments on commit 4554691

Please sign in to comment.