get_sqp: Extract variable estimates from the SQP 3.0 prediction...

Description Usage Arguments Details Value See Also Examples

View source: R/get_sqp.R

Description

Extract variable estimates from the SQP 3.0 prediction algorithm

Usage

1
2
get_sqp(study, question_name, country, lang, all_columns = FALSE,
  authorized = TRUE)

Arguments

study

string with the name of the study. Upper and lower cases are ignored and regular expressions are supported.

question_name

A vector of strings specifying the variable names. A search is performed for similar names from all variables in the study. Upper or lower case is ignored and regular expressions are supported.

country

the country where the question was applied in two letter ISO code. See the ISO two letter country name list here for all options. Upper or lower case is ignored.

lang

the language the question should be in, in a three letter character. See the ISO three letter country name list here for all options. Upper or lower case is ignored. This should be a language spoken in country.

all_columns

a logical stating whether to extract all available columns from the SQP 3.0 database. See the details section for a list of all possible variables.

authorized

TRUE to return only the authorized prediction or FALSE to return all available predictions. If set to FALSE a warning is issued reminding the user to pick one prediction for each variable based on the user_id and user_username columns.

Details

get_sqp is a simple wrapper around find_questions, find_studies and get_estimates for a direct downloading strategy of the SQP data. For a lower-level approach use a combination of these functions to extract SQP data.

SQP predictions can be both 'authorized' predictions, which are performed by the SQP 3.0 software, and 'crowd-sourced' predictions which are added to the database by other users. By default, sqp_data always returns the 'authorized' prediction when it is available. When it is not, it returns the first non-authorized prediction, and so on. If the user wants to choose a specific prediction, then authorized = FALSE will return all available predictions for each question.

If authorized = FALSE and all_columns = FALSE, get_sqp raises an error because there is no way of disentangling which prediction is authorized/unauthorized without the additional user_id column (observed when all_columns = TRUE).

sqp_data returns a four column tibble with the question name and the estimates for quality, reliability and validity. However, if all_columns is set to TRUE the returned tibble contains new columns. Below you can find the descriptionof of all columns:

Value

get_sqp returns a tibble with the predictions. The number of columns depends on the all_columns argument.

See Also

sqp_login for logging in to the SQP 3.0 API through R and find_questions, find_studies and get_estimates for the lower-level approach of extracting estimates.

Examples

 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
## Not run: 

# Log in with sqp_login first. See ?sqp_login
sqp_login()

# 'es' and 'spa' here stands for Spain and Spanish
get_sqp("ESS Round 4", "tvtot", "es", "spa")


get_sqp(
  "ESS Round 4",
  c("tvtot", "ppltrst", "pplfair"),
  "se",
  "swe"
)

# Sweden-Swedish
get_sqp(
  "ESS Round 4",
  c("tvtot", "ppltrst", "pplfair"),
  "se",
  "swe"
)

# Germany-German
get_sqp(
  "ESS Round 1",
  c("vote", "trstplt"),
  "de",
  "deu",
  all_columns = TRUE
)


## End(Not run)

recsm-asqme/sqpr documentation built on May 28, 2020, 4:06 p.m.