tests/testthat/test_recode_as_na_if.R

test_that(desc = "Test condition based NA recoding",
          code = {
            skip_on_oldrel()
            # Change all values in Ozone to NA
            test_recode <-
              head(recode_as_na_if(airquality, sign = "gt", percent_na = 20))
            test_recode_ignore <-
              head(recode_as_na_if(
                airquality,
                sign = "gt",
                percent_na = 20,
                keep_columns = "Ozone"
              ))
            expect_true(is.na(test_recode[1, 1]))
            expect_false(is.na(test_recode_ignore[1, 1]))
            expect_snapshot({
              expect_error(head(
                recode_as_na_if(airquality, sign = "gibberish",
                                percent_na = 20)
              ))
            })
            
            
            
            
          })

Try the mde package in your browser

Any scripts or data that you put into this service are public.

mde documentation built on Feb. 10, 2022, 5:08 p.m.