get_cces_question | R Documentation |
Get one column of outcome questions for each model
get_cces_question(
qcode,
year,
qID,
dataframe = NULL,
y_named_as = "response",
data_dir = "data/input/cces",
verbose = TRUE
)
qcode |
A string, the variable name of the outcome variable of interest,
exactly as it appears in the CCES dataset. Together with |
year |
A string for the year the question was asked, which defines the
the dataset. If using a dataset from the cumulative, set to |
qID |
A string, the user's unique name for the question. For example, we use the syntax in our question table. |
dataframe |
An optional argument to pass the entire CCES dataframe in-environment.
If left empty, this will supersede the arguments |
y_named_as |
What to name the response variable. Defaults to "response", which is also the default assumption for cces_join_slim. |
data_dir |
A path for the directory where flat files for the CCES common content is
stored. Currently the data must be of the form |
verbose |
whether to print a message; defaults to TRUE |
This transformation currently only supports Yes/No questions. For some common ordinal questions that can, with manual recodes, be set to a Yes/No question, there is some hard-coding of the recode in the question. In the future, this should be defined outside of the function in a taxonomy.
A three-column dataframe with the columns
The year
The respondent identifier within year
The question ID
The outcome question, of class factor
The object will also have an attribute called question
, which will save
the question identifier qID
# with sample data
get_cces_question("pid3", dataframe = cc18_samp, year = 2018, qID = "pid3")
# need data/input/cces/cces_2018.rds to run this
## Not run:
get_cces_question(qcode = "CC18_326", year = "2018", qID = "TCJA")
# A tibble: 60,000 x 4
# year case_id qID response
# <int> <int> <chr> <fct>
# 1 2018 123464282 TCJA Support
# 2 2018 170169205 TCJA Support
# 3 2018 175996005 TCJA Support
# 4 2018 176818556 TCJA Oppose
# 5 2018 202120533 TCJA Oppose
# 6 2018 226449148 TCJA Oppose
# 7 2018 238205342 TCJA Oppose
# 8 2018 238806466 TCJA Support
# 9 2018 267564481 TCJA Support
# … with 59,991 more rows
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.