HEGSRR / OR-Reproducibility-in-Geography-Survey

Survey of reproducibility in geography from random sample of authors publishing in geography journals.
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

reordering factors for data legibility #1

Closed josephholler closed 2 years ago

josephholler commented 2 years ago

Is it possible to preserve a more sensible order for the factors of ordinal variables in our data frame?

If factors are never ordered correctly through the workflow of exporting from Qualtrics and into R, then we can manually override the order for a single variable with code like this:

survey_resp$Q8_1 <- factor(survey_resp$Q8_1, c("Strongly disagree", "Disagree", "Agree", "Strongly agree", ""), ordered = TRUE)

and then save the data also as an rds file in addition to CSV. Hopefully that approach can be scaled up easily with loops and lists for our different types of ordinal responses.

josephholler commented 2 years ago

Another option may be to use the SPSS file format. Although it is proprietary, it contains both values and labels and the GNU PSPP open source project has documented the file format. The haven package can import this, with read_sav, resulting in a data frame having numerical values and qualitative labels. Similar, but not quite the same as using vectors. The labelled and expss packages help work with this type of data structure. IDK if you think it's easier to use the previous style of code to reorder factors from our CSV data import (advantage: all the data cleaning code will still work), or if its easier to download the data in SPSS format and use functions from haven and expss and/or labelled to manipulate the data.
These expss examples make it look very easy to do some good-looking data exploration in R: https://cran.r-project.org/web/packages/expss/vignettes/tables-with-labels.html These labelled functions make it look easy to convert to data frames with factors or do other useful things: e.g. df %>% to_factor() is to convert all labelled vectors and only labelled vectors into factors: https://raw.githubusercontent.com/rstudio/cheatsheets/main/labelled.pdf

josephholler commented 2 years ago

commit 2928e5e973ab4288b9ef6092f750b9758976b6d9 shows converting a batch of similar questions into factors. In my most recent R install, the CSV imports as character types, not factors.

josephholler commented 2 years ago

It may be better to use Qualtrics specific tools, e.g.

josephholler commented 2 years ago

cancel the QualtricsTools idea: it is programmed for legacy Qualtrics outputs that are no longer supported.

still, the API would be helpful: can ya'll see if your ASU API is enabled & whether we can connect to the survey directly using qualtRics package?

josephholler commented 2 years ago

coded most factors in 89854d348988c02227d20b7da1171e0e98fca7c6