Skip to content

Commit

Permalink
scoping issue
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Sep 7, 2023
1 parent dc9db29 commit a2c233c
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions tests/testthat/test-recode_into.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,27 +189,28 @@ test_that("recode_into, make sure recode works with missing in original variable
data(mtcars)
mtcars$mpg[c(3, 10, 12, 15, 16)] <- NA
mtcars$cyl[c(2, 15, 16)] <- NA
d <<- as.data.frame(mtcars)
out1 <- recode_into(
mtcars$mpg > 20 & mtcars$cyl == 6 ~ 1,
mtcars$mpg <= 20 ~ 2,
mtcars$cyl == 4 ~ 3,
d$mpg > 20 & d$cyl == 6 ~ 1,
d$mpg <= 20 ~ 2,
d$cyl == 4 ~ 3,
default = 0
)
out2 <- recode_into(
mtcars$mpg > 20 & mtcars$cyl == 6 ~ 1,
mtcars$mpg <= 20 ~ 2,
d$mpg > 20 & d$cyl == 6 ~ 1,
d$mpg <= 20 ~ 2,
default = 0
)
out3 <- recode_into(
mtcars$mpg > 20 & mtcars$cyl == 6 ~ 1,
mtcars$mpg <= 20 ~ 2,
mtcars$cyl == 4 ~ 3,
d$mpg > 20 & d$cyl == 6 ~ 1,
d$mpg <= 20 ~ 2,
d$cyl == 4 ~ 3,
default = 0,
preserve_na = FALSE
)
out4 <- recode_into(
mtcars$mpg > 20 & mtcars$cyl == 6 ~ 1,
mtcars$mpg <= 20 ~ 2,
d$mpg > 20 & d$cyl == 6 ~ 1,
d$mpg <= 20 ~ 2,
default = 0,
preserve_na = FALSE
)
Expand Down Expand Up @@ -238,7 +239,7 @@ test_that("recode_into, make sure recode works with missing in original variable
)
)
expect_identical(
out3,
out4,
c(
1, 0, 0, 1, 2, 2, 2, 0, 0, 0, 2, 0, 2, 2, 0, 0, 2, 0, 0, 0,
0, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 0
Expand Down

0 comments on commit a2c233c

Please sign in to comment.