-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
107 lines (84 loc) · 3.48 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# qualtdict
**License:** [MIT](https://opensource.org/licenses/MIT)
<!-- badges: start -->
[](https://www.repostatus.org/#active)
[](https://github.com/lyh970817/qualtdict/actions/workflows/check-standard.yaml)
[](https://github.com/lyh970817/qualtdict/actions/workflows/test-coverage.yaml)
[](https://app.codecov.io/gh/lyh970817/qualtdict?branch=master)
<!-- badges: end -->
[Qualtrics](https://www.qualtrics.com/) is an online survey and data
collection software platform. The qualtdict R package builds on the
[qualtRics](https://github.com/ropensci/qualtRics) R package which
implements the retrieval of survey data using the Qualtrics API and aims to
reduce the pre-processing steps needed in analyzing such surveys. The
current package makes more comprehensive use of the survey metadata and
generates a variable dictionary including most of the information essential
for data processing and analysis. It also uses a modified version of the
RAKE algorithm by
[Rose. et al.](https://media.wiley.com/product_data/excerpt/22/04707498/0470749822.pdf) implemented in the package
[slowraker](https://github.com/cran/slowraker) to generate meaningful names
for all variables in the survey, as well as adding a comprehensive set of
metadata attributes that uniquely identifies each variable.
## Installation
This package can be installed with the
[remotes](https://cran.r-project.org/package=remotes) package.
```{r eval=FALSE}
install.packages("remotes")
remotes::install_github("lyh970817/qultdict")
```
## Example
You need to first register your Qualtrics credentials with the function
`qualtrics_api_credentials` exported from the package
[qualtRics](https://www.qualtrics.com/).
```{r, eval=FALSE}
library(qualtdict)
qualtrics_api_credentials(
api_key = "<YOUR-QUALTRICS_API_KEY>",
base_url = "<YOUR-QUALTRICS_BASE_URL>",
install = TRUE
)
```
You can then generate a variable dictionary.
```{r, eval=FALSE}
mydict <- dict_generate("SV_4YyAHbAxpdbzacl", var_name = "question_name")
```
You may wish to generate meaningful variable names (if you don't already
have them in the survey) in the dictionary. If doing so, preferably you
would also want to define a function that extracts block prefixes from
block names.
```{r, eval=FALSE}
# Define a block prefix extraction function
block_pattern <- function(x) {
substring(x, 1, 3)
}
mydict <- dict_generate("SV_4YyAHbAxpdbzacl",
var_name = "easy_name",
block_pattern = block_pattern,
block_sep = "."
)
```
You might want to check for potential mistakes in the survey with
`dict_validate`.
```{r, eval=FALSE}
dict_validate(mydict)
```
And use the dictionary to download
[sjlabelled](https://github.com/strengejacke/sjlabelled) survey data.
```{r, eval=FALSE}
survey_dat <- get_survey_data(mydict,
unanswer_recode = -77,
unanswer_recode_multi = 0
)
```