Title: | Access the Canadian Election Study Datasets |
---|---|
Description: | Makes accessing and loading the Canadian Election Study (<http://www.ces-eec.ca/>, <https://ces-eec.arts.ubc.ca/>, <https://search1.odesi.ca/#/>) surveys into the R workspace more efficient by downloading a requested survey and loading it as a data object. This removes the need to locate, download, load, and change working directories when working with the Canadian Election Study surveys. |
Authors: | Paul A. Hodgetts [aut, cre], Rohan Alexander [aut] |
Maintainer: | Paul A. Hodgetts <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-11-20 04:05:35 UTC |
Source: | https://github.com/hodgettsp/cesr |
get_ces()
creates a dataframe object for a requested Canadian Election Study
survey using an associated survey code to call and download
the survey dataset. On creation of the data object, prints out the associated citation for use with
the requested dataset and a link to the original location of the data file.
get_ces(srvy, pos = 1)
get_ces(srvy, pos = 1)
srvy |
A CES survey code call. See Survey Code Calls below.
|
pos |
Environment assignment. Defaults to 1, which is an assignment to the global environment. |
Datasets are loaded using .dta, .sav, or .tab file types. See File Types below for a list of included
CES datasets and their file type.
To quickly convert a dataset's values to factor type use
labelled::to_factor()
on the dataset.
ces2019_web
calls 2019 CES online survey dataset.
ces2019_phone
calls 2019 CES phone survey dataset.
ces2015_web
calls 2015 CES online survey dataset.
ces2015_phone
calls 2015 CES phone survey dataset.
ces2015_combo
calls 2015 CES combined (online/phone) dataset.
ces2011
calls 2011 CES survey dataset.
ces2008
calls 2008 CES survey dataset.
ces2004
calls 2004 CES survey dataset.
ces0411
calls 2004-2011 CES survey dataset.
ces0406
calls 2004-2006 CES survey dataset.
ces2000
calls 2000 CES survey dataset.
ces1997
calls 1997 CES survey dataset.
ces1993
calls 1993 CES survey dataset.
ces1988
calls 1988 CES survey dataset.
ces1984
calls 1984 CES survey dataset.
ces1974
calls 1974 CES survey dataset.
ces7480
calls 1974-1980 CES survey dataset.
ces72_jnjl
calls 1972 June-July CES survey dataset.
ces72_sep
calls 1972 September CES survey dataset.
ces72_nov
calls 1972 November CES survey dataset.
ces1968
calls 1968 CES survey dataset.
ces1965
calls 1965 CES survey dataset.
CES 2019 online survey. Loaded as a .dta file type.
CES 2019 phone survey. Loaded as a .tab file type.
CES 2015 online survey. Loaded as a .dta file type.
CES 2015 phone survey. Loaded as a .dta file type.
CES 2015 combined survey. Loaded as a .dta file type.
CES 2011 survey. Loaded as a .dta file type.
CES 2008 survey. Loaded as a .sav file type.
CES 2004 survey. Loaded as a .sav file type.
CES 2004-2011 surveys. Loaded as a .dta file type.
CES 2004-2006 surveys. Loaded as a .sav file type.
CES 2000 survey. Loaded as a .sav file type.
CES 1997 survey. Loaded as a. sav file type.
CES 1993 survey. Loaded as a .sav file type.
CES 1988 survey. Loaded as a .sav file type.
CES 1974 survey. Loaded as a .sav file type.
CES 1974-1980 surveys. Loaded as a .sav file type.
CES 1972 June-July surveys. Loaded as a .sav file type.
CES 1972 September survey. Loaded as a .sav file type.
CES 1972 November survey. Loaded as a .sav file type.
CES 1968 survey. Loaded as a .sav file type.
CES 1965 survey. Loaded as a .sav file type.
Incorrect (a non-existent survey code) will stop the function process and return an associated error message. Repeated code calls will load in the raw version of the requested table.
Due to the naming of the columns in the 1965 and 1968 datasets it is recommended to download the associated codebook for the requested dataset.
The called srvy
at the designated environment position pos
.
Default environment position is set to be the global environment.
get_cescodes()
function help.
## Not run: # call the 2019 CES online survey get_ces("ces2019_web") # convert variables to factor labelled::to_factor(ces2019_web) # preview dataset head(ces2019_web) ## End(Not run)
## Not run: # call the 2019 CES online survey get_ces("ces2019_web") # convert variables to factor labelled::to_factor(ces2019_web) # preview dataset head(ces2019_web) ## End(Not run)
get_cescodes()
prints out a data frame of the CES survey codes and the associated calls.
Provides a quick way of looking up a CES survey code and the associated call.
get_cescodes(indx = 22)
get_cescodes(indx = 22)
indx |
A numeric value that determines the number of survey codes returned. Default is set to 22, or the total set of survey codes. |
Items under the Survey Code Calls and Index Code Calls can be copied and used with the get_ces()
function.
ces2019_web
2019 CES online survey dataset.
ces2019_phone
2019 CES phone survey dataset.
ces2015_web
2015 CES online survey dataset.
ces2015_phone
2015 CES phone survey dataset.
ces2015_combo
2015 CES combined (online/phone) dataset.
ces2011
2011 CES survey dataset.
ces2008
2008 CES survey dataset.
ces2004
2004 CES survey dataset.
ces0411
2004-2011 CES survey dataset.
ces0406
2004-2006 CES survey dataset.
ces2000
2000 CES survey dataset.
ces1997
1997 CES survey dataset.
ces1993
1993 CES survey dataset.
ces1988
1988 CES survey dataset.
ces1984
1984 CES survey dataset.
ces1974
1974 CES survey dataset.
ces7480
1974-1980 CES survey dataset.
ces72_jnjl
1972 June-July CES survey dataset.
ces72_sep
1972 September CES survey dataset.
ces72_nov
1972 November CES survey dataset.
ces1968
1968 CES survey dataset.
ces1965
1965 CES survey dataset.
"ces2019_web"
calls 2019 CES online survey dataset.
"ces2019_phone"
calls 2019 CES phone survey dataset.
"ces2015_web"
calls 2015 CES online survey dataset.
"ces2015_phone"
calls 2015 CES phone survey dataset.
"ces2015_combo"
calls 2015 CES combined (online/phone) dataset.
"ces2011"
calls 2011 CES survey dataset.
"ces2008"
calls 2008 CES survey dataset.
"ces2004"
calls 2004 CES survey dataset.
"ces0411"
calls 2004-2011 CES survey dataset.
"ces0406"
calls 2004-2006 CES survey dataset.
"ces2000"
calls 2000 CES survey dataset.
"ces1997"
calls 1997 CES survey dataset.
"ces1993"
calls 1993 CES survey dataset.
"ces1988"
calls 1988 CES survey dataset.
"ces1984"
calls 1984 CES survey dataset.
"ces1974"
calls 1974 CES survey dataset.
"ces7480"
calls 1974-1980 CES survey dataset.
"ces72_jnjl"
calls 1972 June-July CES survey dataset.
"ces72_sep"
calls 1972 September CES survey dataset.
"ces72_nov"
calls 1972 November CES survey dataset.
"ces1968"
calls 1968 CES survey dataset.
"ces1965"
calls 1965 CES survey dataset.
A printout of a designated number of Canadian Election Study survey codes and
associated character codes used for the get_ces()
function.
get_ces()
function help.
# print out CES code calls get_cescodes() # call 1984 CES survey get_ces("ces1984")
# print out CES code calls get_cescodes() # call 1984 CES survey get_ces("ces1984")
get_decon() creates a non-exhaustive dataset under the name decon consisting of 21 variables with renamed columns from the demographics, ideology, and economy sections of the 2019 CES online survey.
get_decon(pos = 1)
get_decon(pos = 1)
pos |
Environment assignment. Defaults to 1, which is an assignment to the global environment. decon Variables
|
NAs have not been removed. The politically left/right question
variables (lr_bef
and lr_aft
) have also been joined into one column under the
name lr_scale
. All variables have been converted to factor type using
labelled::to_factor
and are listed below.
The designed dataframe as a 'tbl_df' object under the name decon.
For further details, see https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/DUS88V Stephenson, Laura B; Harell, Allison; Rubenson, Daniel; Loewen, Peter John, 2020, "2019 Canadian Election Study - Online Survey", doi:10.7910/DVN/DUS88V, Harvard Dataverse, V1
## Not run: # call decon dataset get_decon() # preview decon head(decon) ## End(Not run)
## Not run: # call decon dataset get_decon() # preview decon head(decon) ## End(Not run)
get_preview()
creates a truncated dataframe for a requested Canadian Election Study
survey using an associated code to call and download
the survey dataset.
get_preview(srvy, obs = 6, pos = 1)
get_preview(srvy, obs = 6, pos = 1)
srvy |
A CES survey code call. See Survey Code Calls below.
|
obs |
A numerical value that determines the number of observations returned.
If a value for |
pos |
Environment assignment. Defaults to 1, which is an assignment to the global environment. |
Datasets are loaded using either .dta or .sav file types
and converted to factor type using the to_factor()
function
from the labelled
package.
get_preview()
uses the same survey code calls as the get_ces()
function.
These survey code calls are listed below.
ces2019_web
calls 2019 CES online survey dataset.
ces2019_phone
calls 2019 CES phone survey dataset.
ces2015_web
calls 2015 CES online survey dataset.
ces2015_phone
calls 2015 CES phone survey dataset.
ces2015_combo
calls 2015 CES combined (online/phone) dataset.
ces2011
calls 2011 CES survey dataset.
ces2008
calls 2008 CES survey dataset.
ces2004
calls 2004 CES survey dataset.
ces0411
calls 2004-2011 CES survey dataset.
ces0406
calls 2004-2006 CES survey dataset.
ces2000
calls 2000 CES survey dataset.
ces1997
calls 1997 CES survey dataset.
ces1993
calls 1993 CES survey dataset.
ces1988
calls 1988 CES survey dataset.
ces1984
calls 1984 CES survey dataset.
ces1974
calls 1974 CES survey dataset.
ces7480
calls 1974-1980 CES survey dataset.
ces72_jnjl
calls 1972 June-July CES survey dataset.
ces72_sep
calls 1972 September CES survey dataset.
ces72_nov
calls 1972 November CES survey dataset.
ces1968
calls 1968 CES survey dataset.
ces1965
calls 1965 CES survey dataset.
Incorrect (a non-existent survey code) will stop the function process and return associated error messages. Repeated code calls will load in an unaltered version of the requested table.
Due to the naming of the columns in the 1965 and 1968 datasets it is recommended to download the associated codebook for the requested dataset.
The truncated version of the requested survey dataset srvy
with the set number of observations obs
to the designated environment pos
.
get_ces()
function help.
get_cescodes()
function help.
## Not run: # print out CES call codes get_cescodes() # call the 1993 CES dataset get_ces("ces1993") # preview the first 10 observations of the dataset get_preview("ces1993", 10) ## End(Not run)
## Not run: # print out CES call codes get_cescodes() # call the 1993 CES dataset get_ces("ces1993") # preview the first 10 observations of the dataset get_preview("ces1993", 10) ## End(Not run)
get_question() prints out the survey question associated with a given column in a given dataset name.
get_question(do, q)
get_question(do, q)
do |
a CES survey data object (given as a character string) |
q |
a column name in a CES survey data object (given as a character string) |
The order of the parameters for get_question
are data object then column name.
Both parameters must be character strings and cannot be reversed.
To return the associated survey question, the get_question
function relies
on the var_label
function from the labelled
package.
The associated question q
in a loaded dataset do
.
get_ces()
function help.
get_cescodes()
help.
# print out CES code calls get_cescodes() # call CES survey get_ces("ces1988") # request the survey question for column a6 get_question("ces1988", "a6")
# print out CES code calls get_cescodes() # call CES survey get_ces("ces1988") # request the survey question for column a6 get_question("ces1988", "a6")