Conditionally change all column values to NA
recode_as_na_if(df, sign = "gteq", percent_na = 50, keep_columns = NULL, ...)
A data.frame object
Character. One of gteq,lteq,lt,gt or eq which refer to greater than(gt) or equal(eq) or less than(lt) or equal to(eq) respectively.
The percentage to use when dropping columns with missing values
Columns that should be kept despite meeting the target percent_na criterion(criteria)
Other arguments to "percent_missing"
A `data.frame` with the target columns populated with `NA`s.
head(recode_as_na_if(airquality, sign="gt", percent_na=20))
#> Ozone Solar.R Wind Temp Month Day
#> 1 NA 190 7.4 67 5 1
#> 2 NA 118 8.0 72 5 2
#> 3 NA 149 12.6 74 5 3
#> 4 NA 313 11.5 62 5 4
#> 5 NA NA 14.3 56 5 5
#> 6 NA NA 14.9 66 5 6