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)

Arguments

srvy

A CES survey code call. See Survey Code Calls below. srvy value must be a character string.

obs

A numerical value that determines the number of observations returned. If a value for obs is not given, then default value is 6 observations. Variable must be given as a numerical value.

pos

Environment assignment. Defaults to 1, which is an assignment to the global environment.

Value

The truncated version of the requested survey dataset srvy with the set number of observations obs to the designated environment pos.

Details

Datasets

Datasets are loaded using either .dta or .sav file types and converted to factor type using the to_factor() function from the labelled package.

Survey Code Calls

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/Repeated Code Calls

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.

Extra Notes

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.

See also

get_ces() function help. get_cescodes() function help.

Examples

if (FALSE) {
# 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)
}