Open b1azk0 opened 3 years ago
I think what you want is label = TRUE, convert = FALSE
:
library(qualtRics)
library(tidyverse)
sourdough <- fetch_survey("SV_5BJRo2RGHajIlOB", label = TRUE, convert = FALSE, force_request = TRUE)
#> | | | 0% | |======================================================================| 100%
#>
#> ── Column specification ────────────────────────────────────────────────────────
#> cols(
#> .default = col_character(),
#> StartDate = col_datetime(format = ""),
#> EndDate = col_datetime(format = ""),
#> Progress = col_double(),
#> `Duration (in seconds)` = col_double(),
#> Finished = col_logical(),
#> RecordedDate = col_datetime(format = ""),
#> RecipientLastName = col_logical(),
#> RecipientFirstName = col_logical(),
#> RecipientEmail = col_logical(),
#> ExternalReference = col_logical(),
#> LocationLatitude = col_double(),
#> LocationLongitude = col_double(),
#> Q1007 = col_double(),
#> Q1_DO_1 = col_double(),
#> Q1_DO_2 = col_double(),
#> Q1_DO_3 = col_double(),
#> Q1_DO_4 = col_double(),
#> Q1_DO_5 = col_double(),
#> SolutionRevision = col_double(),
#> FL_6_DO_FL_7 = col_double()
#> # ... with 4 more columns
#> )
#> ℹ Use `spec()` for the full column specifications.
# this would be ordered otherwise
sourdough %>% count(Q1002)
#> # A tibble: 8 × 2
#> Q1002 n
#> <chr> <int>
#> 1 Associate degree in college (2-year) 11
#> 2 Bachelor's degree in college (4-year) 15
#> 3 Doctoral degree 19
#> 4 High school graduate (high school diploma or equivalent including GED) 16
#> 5 Less than high school degree 12
#> 6 Master's degree 20
#> 7 Professional degree (JD, MD) 17
#> 8 Some college but no degree 15
Created on 2021-11-09 by the reprex package (v2.0.1)
That should get you labels but not try to convert them to an ordered factor. It will not be a factor, but rather a character; if you want to convert it to an unordered factor, you could do that afterwards.
Thank you @juliasilge . I thought there is a way to do it at once - convert to factor without ordering in a single step at import.
I don't believe currently. We have this longstanding comment about adding support for something like ordered = FALSE
:
https://github.com/ropensci/qualtRics/blob/6e64d2c7d49d113a86a63f9f44fd6eb9f129fc83/R/utils.R#L486
But it is not currently possible. You can either do the ordered factor based on your choiceText
from the survey or a character.
Hi, is it possible to pass a
ordered = FALSE
flag tofetch_survey()
along withconvert = T, label = T
?The reason I'm asking is, that I only need labels for my factor columns and it looks as if ordering is not working for some reason with my survey.
Variables that are originally 7 level (properly recoded on qualtrics side) produce errors
and get imported as
NAs
only:While, actually there should be responses:
df<-fetch_survey("SV_6fj5q4AwIjhOU0m", time_zone = "Europe/Berlin", force_request = T, start_date = "2021-11-01", convert = F, label = F, include_display_order = F)