Retrieves PolarCAP data for defined countries and years. Returns data in tidy format. For wide
format, or to return a polarization estimate as a scalar, use get.PolarCAP()
.
Usage
melt.PolarCAP(
countries = NA,
years = NA,
type = c("ideology", "affect"),
include.se = FALSE
)
Arguments
- countries
a character vector of countries to be retrieved. See Details.
- years
a numeric vector of years to be retrieved.
- type
a character vector indicating which polarization estimates should be returned. Must be
"ideology"
,"affect"
, or both.- include.se
a logical indicating whether standard errors should be returned. Defaults to
FALSE
.
Value
a data frame with columns corresponding to country names, country ISO3 codes, years,
polarization types given in type
, polarization estimates, and associated standard errors (if
include.se = TRUE
).
Details
Ideally, country names passed to countries
would be ISO 3166-1 alpha-3 country codes
(case-insensitive). However, melt.PolarCAP()
will accept country names in almost any language or
format and attempt to convert them to ISO3 codes by calling to.ISO3()
.
melt.PolarCAP()
will alert the user to any country names still unrecognized after this
conversion and return results only for those which are recognized.
Examples
melt.PolarCAP("USA", c(2018, 2019), "ideology", include.se = TRUE)
#> country country_code year type estimate se notes
#> 1 United States USA 2018 ideology 0.6819618 0.009698904 <NA>
#> 2 United States USA 2019 ideology 0.7611854 0.010172854 <NA>
melt.PolarCAP("USA", c(2018, 2019), c("ideology", "affect"), include.se = TRUE)
#> country country_code year type estimate se notes
#> 1 United States USA 2018 ideology 0.6819618 0.009698904 <NA>
#> 2 United States USA 2018 affect 0.7726953 0.011448660 <NA>
#> 3 United States USA 2019 ideology 0.7611854 0.010172854 <NA>
#> 4 United States USA 2019 affect 0.7283458 0.011798293 <NA>