Closed Haunfelder closed 5 months ago
Hmmmmm, I might need more information to understand what you are saying. Take a look at this example survey: https://conjoint.qualtrics.com/jfe/form/SV_3gbwq8aJgqPwQDP (Also, feel free to fill it out. 😜 )
That first question is multiple choice, and when I look at choiceText
, I get what I believe should be the factor levels, at least after remove_html()
gets run:
[1] "<span style=\"color:#8e44ad;\">Daily</span>"
[2] "Weekly"
[3] "Once a <span style=\"background-color:#9b59b6;\">month</span>"
[4] "<a href=\"https://www.instagram.com/p/B5qn5ath0ij/?hl=en\">Less often</a>"
[5] "Do not use"
For this question, variableName
is NULL
for all the options. Do you see something different?
Thanks @juliasilge, I realize this isn't much to go on. I'm having difficulty creating a reprex because I don't have a Qualtrics account with my organization and I don't have API access with my free account. The problem appears for questions where Recode Values and Variable Names are both checked and the names don't match the levels in the question. The "choiceText" returned by fetch_survey matches the capitalized values in the screenshot, while the responses come back from the API with the variable names. This error only happens when label and convert are both T, because it calls infer_data_types.
I suspect that responses are returned from the export-responses endpoint with "variableName" levels if they exist, otherwise "choiceText". I know this is a lot to ask, but is that enough to make a reprex?
It looks like the wrap_mc function in the utils.R script uses "choiceText" from the survey metadata as the factor levels, which isn't guaranteed to match the response values returned from fetchsurveys. This causes an error if, for example, the choice text has a capital letter in it, but the variable name does not. It seems like "variableName" would be a better choice for the levels, though I am new to Qualtrics, so I may be misinterpreting these values.
https://github.com/ropensci/qualtRics/blob/72bde4e84805d659c98e77c2b92e12a13513081f/R/utils.R#L363