Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle ordered factor when multiple choice question uses recoded variable names #343

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Haunfelder
Copy link

If variableNames are non-null, use them for factor levels, otherwise use the choiceText. It may be more appropriate to add an explicit flag to the function to not cause any issues with people relying on choiceText. From my testing, all cases where variableNames do not match choiceText causes an error in fetch_survey as explained in the issue.

Fixes #342

@juliasilge
Copy link
Collaborator

@jmobrien do you mind taking a look at this, to see what you think? I don't think I've done much with variableNames in my real work.

@Haunfelder
Copy link
Author

If it helps, here's some more details about the error. I'm fetching a survey that has a multiple choice question with recoding as described in the issue. I use the following code,

test = fetch_survey(surveyID = surveyID, label = T, convert = T,
                    verbose = T, force_request = T)

which results in the following warning.

image

The values of the variable all are set to NA because the factor levels do not match the values returned by the survey API. Here's a picture of the problems output,

image

The expected value is "Tenure or Tenure-track Professor", but the actual value returned from the API is "tenure or tenure-track professor".

I think you'll be able to re-create the issue with a single question survey that uses recoding and variable names, but let me know if you need any more details.

@jmobrien
Copy link
Collaborator

jmobrien commented May 10, 2024 via email

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.

Ordered factor conversion for multiple choice question
3 participants