Science Score: 49.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 5 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (18.8%) to scientific vocabulary
Repository
R package "PolarCAP"
Basic Info
- Host: GitHub
- Owner: imehlhaff
- License: cc0-1.0
- Language: R
- Default Branch: master
- Homepage: http://imehlhaff.net/PolarCAP/
- Size: 2.17 MB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
PolarCAP: Access the Polarization in Comparative Attitudes Project
<!--
-->
<!--
-->
<!-- badges: end -->
Distributes data from the Polarization in Comparative Attitudes Project. Helper functions enable data retrieval in wide and tidy formats for user-defined countries and years. Provides support for case-insensitive country names in many languages.
Installation
There are two ways to easily install this package in R. To install the stable version released to CRAN, install as normal:
install.packages("PolarCAP")
library(PolarCAP)
To install the most recent development version, first ensure you have the latest version of devtools installed:
{r}
install.packages("devtools")
library(devtools)
Then, run the following code:
{r}
devtools::install_github("imehlhaff/PolarCAP")
Citation
To cite PolarCAP in publications and working papers, please use:
Mehlhaff, Isaac D. Mass Polarization across Time and Space. New York: Cambridge University Press (2025).
For BibTeX users:
@book{Mehlhaffbook,
title = {Mass {{Polarization}} across {{Time}} and {{Space}}},
author = {Mehlhaff, Isaac D.},
year = {2025},
publisher = {{Cambridge University Press}},
location = {{New York}},
doi = {https://doi.org/10.1017/9781009350662}
}
Usage
Most users of this package will be primarily interested in using it to easily retrieve polarization estimates for a defined set of countries and years. For example, let us take the countries and years generated by the following:
r
countries <- rep(c("AUS", "MEX", "USA"), each = 2)
years <- rep(c(2018, 2019), 3)
data <- as.data.frame(cbind(countries, years))
Retrieve Data Frame
One way to retrieve polarization estimates for the countries and years generated above is to pass the vectors of countries and years to get.PolarCAP() or melt.PolarCAP(), which return wide and tidy data frames, respectively:
{r}
get.PolarCAP(countries = countries, years = years, type = c("ideology", "affect"))
melt.PolarCAP(countries = countries, years = years, type = c("ideology", "affect"))
Standard errors of polarization estimates can be retrieved by adding the optional include.se argument, which defaults to FALSE:
{r}
get.PolarCAP(countries = countries, years = years, type = c("ideology", "affect"), include.se = TRUE)
melt.PolarCAP(countries = countries, years = years, type = c("ideology", "affect"), include.se = TRUE)
Retrieve Individual Values
Another way to retrieve polarization estimates for the same set of countries and years is to return only the scalar polarization estimate associated with each country-year. This feature is particularly useful if a user has an imbalanced time series, would prefer to avoid merging data frames, or is working within a dplyr pipeline:
{r}
data$ideology1 <- apply(data, 1, function(x) get.PolarCAP(countries = x[1], years = x[2], type = "ideology", value.only = TRUE))
data <- rowwise(data) %>% mutate(ideology2 = get.PolarCAP(countries = countries, years = years, type = "ideology", value.only = TRUE))
data
A Note on Country Identifiers
The countries defined above are in ISO 3166-1 alpha-3 country code format. This is the preferred input for *.PolarCAP(). However, these functions will accept country names in almost any language or format and attempt to convert them to ISO3 codes by calling to.ISO3(). *.PolarCAP() will alert the user to any country names still unrecognized after this conversion and return results only for those which are recognized. In addition, country codes are case-insensitive. Thus, the following all return the same output:
{r}
get.PolarCAP(countries = c("AUS", "MEX", "USA"), years = 2019, type = "ideology")
get.PolarCAP(countries = c("aus", "MEX", "united states"), years = 2019, type = "ideology")
get.PolarCAP(countries = c("aus", "MEX", "Stati Uniti"), years = 2019, type = "ideology")
Owner
- Name: Isaac Mehlhaff
- Login: imehlhaff
- Kind: user
- Location: Chapel Hill, NC
- Company: UNC-Chapel Hill
- Website: imehlhaff.net
- Repositories: 3
- Profile: https://github.com/imehlhaff
GitHub Events
Total
- Push event: 9
Last Year
- Push event: 9
Packages
- Total packages: 1
-
Total downloads:
- cran 184 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
- Total maintainers: 1
cran.r-project.org: PolarCAP
Access the Polarization in Comparative Attitudes Project
- Homepage: https://github.com/imehlhaff/PolarCAP
- Documentation: http://cran.r-project.org/web/packages/PolarCAP/PolarCAP.pdf
- License: CC0
-
Latest release: 1.0.1
published over 2 years ago
