Skip to content

Conversation

@Dewi-Amaliah
Copy link
Collaborator

@Dewi-Amaliah Dewi-Amaliah commented Aug 4, 2023

Updated SurveyData function to automatically read haven-labelled data to survey question and survey responses

@lauken13 lauken13 requested review from jgabry and lauken13 August 4, 2023 02:29
@Dewi-Amaliah
Copy link
Collaborator Author

Hi all,

Here is the example code of using the haven functionality

survey_dat <- SurveyData$new(feline_survey_haven)
survey_dat$questions()
survey_dat$responses()

@lauken13
Copy link
Owner

lauken13 commented Sep 13, 2023

This is great! Some thoughts:

  • the code is failing on the checks because the new haven labelled data hasn't been documented
  • if there is a variable that is missing labels for the levels BUT is a haven labelled variable, it won't be included e.g:

`survey_dat <- SurveyData$new(feline_survey_haven)
survey_dat$questions()
survey_dat$responses()

generate_dictionary(feline_survey_haven) %>% View()

feline_survey_haven2 <- feline_survey_haven %>%
mutate(pet_own = remove_val_labels(pet_own))

survey_dat <- SurveyData$new(feline_survey_haven2)
survey_dat$questions()
survey_dat$responses()`

  • Do we want to be able to do a mix of labelled and unlabelled?

@lauken13
Copy link
Owner

From the meeting:

  • Decided to have a preference list:
    For each variable:
    -> if it's explicitly named in the function input then use those labels
    -> else if its a haven labelled variable then use those variables
    -> else if its a factor labelled variable then use the factor level names
    -> else if its a binary variable then code 0 or 1 as the label

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants