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

Merged
merged 3 commits into from
Jun 10, 2024

Conversation

Haunfelder
Copy link
Contributor

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
Contributor 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

Copy link
Collaborator

@juliasilge juliasilge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this PR @Haunfelder, and for your patience! 🙌

It would be nice to get this behavior under testing, but we are looking at totally revamping our testing strategy as outlined in #294 (comment) so I don't think it's a high priority for now.

@juliasilge juliasilge merged commit 03f4b66 into ropensci:main Jun 10, 2024
6 checks passed
@Haunfelder
Copy link
Contributor Author

Awesome, thanks @juliasilge! I appreciate you all taking the time to understand the issue I was seeing. The qualtRics package has been very useful for me!

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