Skip to content

Commit

Permalink
Update internal usage of case_when()
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisVaughan committed Jun 1, 2022
1 parent 2f21e8b commit e44b9ab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions R/utils-format.r
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ wrap <- function(..., indent = 0) {
ruler <- function(width = getOption("width")) {
x <- seq_len(width)
y <- case_when(
x %% 10 == 0 ~ as.character((x %/% 10) %% 10),
x %% 5 == 0 ~ "+",
TRUE ~ "-"
x %% 10 == 0, as.character((x %/% 10) %% 10),
x %% 5 == 0, "+",
.default = "-"
)
cat(y, "\n", sep = "")
cat(x %% 10, "\n", sep = "")
Expand Down
6 changes: 3 additions & 3 deletions data-raw/starwars.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ starwars <- mutate(starwars,
species = ifelse(name == "R4-P17", "Droid", species), # R4-P17 is a droid
sex = ifelse(species == "Droid", "none", sex), # Droids don't have biological sex
gender = case_when(
sex == "male" ~ "masculine",
sex == "female" ~ "feminine",
TRUE ~ unname(genders[name])
sex == "male", "masculine",
sex == "female", "feminine",
.default = unname(genders[name])
)
)

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-colwise-select.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ test_that("rename_at() handles empty selection (#4324)", {
})

test_that("rename_all/at() call the function with simple character vector (#4459)", {
fun <- function(x) case_when(x == 'mpg' ~ 'fuel_efficiency', TRUE ~ x)
fun <- function(x) case_when(x == 'mpg', 'fuel_efficiency', .default = x)
out <- rename_all(mtcars,fun)
expect_equal(names(out)[1L], 'fuel_efficiency')

Expand Down

0 comments on commit e44b9ab

Please sign in to comment.