# Use whole data frame
nice_na(airquality)
# Use selected columns explicitly
nice_na(airquality,
vars = list(
c("Ozone", "Solar.R", "Wind"),
c("Temp", "Month", "Day")
)
)
# If the questionnaire items start with the same name, e.g.,
set.seed(15)
fun <- function() {
c(sample(c(NA, 1:10), replace = TRUE), NA, NA, NA)
}
df <- data.frame(
ID = c("idz", NA),
open_1 = fun(), open_2 = fun(), open_3 = fun(),
extrovert_1 = fun(), extrovert_2 = fun(), extrovert_3 = fun(),
agreeable_1 = fun(), agreeable_2 = fun(), agreeable_3 = fun()
)
# One can list the scale names directly:
nice_na(df, scales = c("ID", "open", "extrovert", "agreeable"))
Run the code above in your browser using DataLab