find_questions: Extract question information from specific studies

Description Usage Arguments Value Examples

View source: R/questions.R

Description

Use find_question to search for information on a given question in a study and get_questions to return all the question in a study.

Usage

1
2
3
find_questions(study, question_name, all_columns = FALSE)

get_questions(study, all_columns = FALSE)

Arguments

study

a character specifying the name of the desired study. Find with find_studies or get_studies.

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.

all_columns

TRUE or FALSE stating whether to return all columns. By default it returns the 'id' of the question, the 'study_id', the 'short_name' of the question and the 'country_iso' and 'language_iso' of the question. If set to TRUE, it returns additional columns with the specific wording of the question, answer options, etc..

Value

a tibble

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
## Not run: 
# Set login information here. See ?sqp_login
sqp_login()

# 1 is the study ESS round 1
find_questions("ESS round 1", "tvtot")

# If that doesn't fit, then use get_questions and search for the question
# manually through filtering:

all_questions <- get_questions("ESS round 1")
cnt_filt <- all_questions$country_iso == "ES"
lang_filt <- all_questions$language_iso == "spa"
var_filt <- grepl("TvTot", all_questions$short_name)

# The desired "TvTot" variable from Spain, in Spanish
all_questions[cnt_filt & lang_filt & var_filt, ]

# Can also search for several variables in one call

find_questions("ESS round 1", c("tvpol", "tvtot"))

# Or use regular expressions. For example, to find all variables
# that begin with tv

find_questions(1, "^tv")

## End(Not run)

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