# \donttest{
if (requireNamespace("haven", quietly = TRUE)) {
# Roundtrip through a temporary .sav file (with your own data,
# simply pass its path instead)
tmp <- tempfile(fileext = ".sav")
write_spss(survey_data, tmp)
data <- read_spss(tmp)
# Standard R operations work normally (NAs are excluded)
mean(data$life_satisfaction, na.rm = TRUE)
# frequency() shows each missing type separately
data |> frequency(life_satisfaction)
unlink(tmp)
}
# }
Run the code above in your browser using DataLab