| Title: | Data and Functions for "An R Companion to Political Analysis, Fourth Edition" |
|---|---|
| Description: | Provides teaching-oriented functions and datasets for "An R Companion to Political Analysis, Fourth Edition" (forthcoming 2026). Functions produce readable tables and graphics for descriptive statistics, data transformation, confidence intervals, hypothesis testing, comparisons, cross-tabulation, and linear and logistic regression. Sampling weights are supported where appropriate, and analysis functions return reusable results for further examination. The package also includes curated political datasets designed for classroom instruction and independent practice. See Edwards and Pollock (forthcoming 2026) <https://www.poliscidata.com/textbooks/r_companion_4e.php>. |
| Authors: | Barry C. Edwards [aut, cre] (ORCID: <https://orcid.org/0009-0005-6699-3820>), Philip H. Pollock III [ctb] |
| Maintainer: | Barry C. Edwards <[email protected]> |
| License: | CC0 |
| Version: | 1.0.0 |
| Built: | 2026-10-24 11:25:27 UTC |
| Source: | https://github.com/cran/RCPA4 |
A student-friendly subset of the 2024 American National Election Study Time Series. Variables were selected and renamed for use in RCPA4 examples. See book Appendix for variable names and descriptions.
A data frame with 5521 rows and 517 variables.
Abortion: self-placement
Position on abortion: self-placement
Years respondent lived at address
Approval of Biden dropping from presidential race
Approval of Joe Biden dropping out of presidential race
Approval of how colleges and universities are run
Approval of Congress handling its job
Approval of Democratic party choosing new candidate
Approval of Diversity, Equity, and Inclusion (DEI)
Approval of House incumbent
Approval of president handling job
Approval of president handling abortion policy
Approval of president handling crime
Approval of president handling economy
Approval of president handling foreign relations
Approve or dissaprove president handling immigration
Approval of Supreme Court decision president immune
Approval of protests against war in Gaza
Approval of Supreme Court handling its job
Approval of transgender people use bathroom that matches gender identity
Approval of vice president handling job
Attention to sexual harassment as gone too far/not far enough
Favor or oppose tax on millionaires
Importance of reducing deficit
Whether business leaders should make political decisions
Agree/disagree: past slavery & discrimination make it difficult for blacks
Agree/disagree: blacks should work their way up without special favors
Agree/disagree: if blacks tried harder they'd be as well off as whites
Agree/disagree: blacks have gotten less than they deserve
Better/worse if man works and woman takes care of home
Congress change votes because of donation to campaign
Congress pass laws that benefit contributor individuals
Congress pass laws that benefit contributor organization
Limits on campaign spending
Interest in following campaigns
How much respondent cares who wins the presidency
2024 Time Series Case ID
Does respondent personally have a cell phone
Should children brought illegally be sent back or allowed to stay
How many children in HH age 0-17
Which child trait more important: curiosity or good manners
Which child trait more important: obedience or self-reliance
Which child trait more important: considerate or well-behaved
Which child trait more important: independence or respect
Satisfaction with the range of choices in elections
Concern that government might undermine the news media
Does respondent consider themself a feminist or anti-feminist
respondent contribute to any other group that supported or opposed candidates
Country would be better off if we just stayed home
How irritated respondent feels about how things are going in the country
Are things in the country on right track
How confident is respondent about that (winner of 2020 election)
How confident is respondent about that (winner of 2024 election)
How confident is respondent about that (Hunter Biden)
How confident is respondent about that (events on January 6, 2021)
How confident is respondent about that (Trump colluded with Russia)
Corruption increased/decreased since Biden became president
How widespread corruption is
Whether courts can stop the government from acting illegally
Effect of COVID on democracy
Personal experience with COVID infection
Effect of COVID on respondent's personal finances
Effect of COVID on national unity
What is the current unemployment rate
Whether respondent dislikes anything about the Democratic Party
Whether respondent likes anything about the Democratic Party
Satisfaction with the democratic process
Whether democracy is preferable to other forms of government
How worried about terrorist attack in near future
How difficult was it for respondent to vote
Discrimination in the US against Asians
Discrimination in the US against blacks
Discrimination in the US against Christians
Discrimination in the US against Hispanics
Discrimination in the US against men
Discrimination in the US against Muslims
Discrimination in the US against whites
Discrimination in the US against women
Discrimination in the US against Gays and Lesbians
Discrimination in the US against transgender people
Economy better or worse in next 12 months
Economic mobility
State of the economy over the past year
effect of illegal immigration on crime rate
Elections make government pay attention
Perceived fairness of elections
If people were treated more fairly we would have fewer problems
Not a big problem if some have more chance in life
Society should make sure everyone has equal opportunity
We'd be better off if worried less about equality
Whether independent experts should make political decisions
How many guns in household
How much money does respondent owe in student loans
Family members living with respondent
Favor/oppose allowing felons to vote
Favor/oppose background checks for gun purchases
Favor or oppose building a wall on border with Mexico
Favor/oppose banning 'assault-style' rifles
Favor/oppose banning transgender girls from K-12 girls sports
Favor or oppose ending birthright citizenship
Favor/oppose free trade agreements
Favor/oppose government trying to reduce income inequality
Favor/oppose increased regulation on greenhouse emissions
Favor/oppose laws protect gays/lesbians against job discrimination
Favor/oppose new limits on imports
Favor/oppose preferential hiring/promotion of blacks
Favor/oppose providing path to citizenship
Favor/oppose right of gay and lesbian couples to legally marry
Favor/oppose requiring vaccines in schools
Favor/oppose requiring ID when voting
Favor or oppose restricting journalist access
Favor/oppose transgender people serve in military
Favor/oppose U.S. giving weapons to help Ukraine fight Russia
Favor/oppose U.S. giving military assistance to Israel
Favor/oppose U.S. giving humanitarian aid to Palestinians
Federal Budget Spending: aid to the poor
Federal Budget Spending: building and repairing highways
Federal Budget Spending: Tightening border security
Federal Budget Spending: dealing with crime
Federal Budget Spending: protecting the environment
Federal Budget Spending: public schools
Federal Budget Spending: Social Security
Federal Budget Spending: welfare programs
Federal government treats blacks or whites better
How afraid respondent feels about the country
How angry respondent feels about the country
How happy respondent feels about the country
How hopeful respondent feels about the country
How nervous respondent feels about the country
How outraged respondent feels about the country
How proud respondent feels about the country
How worried respondent feels about the country
Has respondent done any of the following - borrowed money to pay bills
Has respondent done any of the following - took on credit card debt
Have any family members or close friends lost jobs in last 12 months
How likely respondent able to make all housing payments in next 12 months
How worried is respondent about current financial situation
Has respondent done any of the following - cut down spending
Expected personal financial situation one year from now
Has respondent done any of the following - none of these
Personal financial situation compared with one year ago
Has respondent done any of the following - cancel/postpone major purchase
Has respondent done any of the following - dipped into savings
Number of financial strain actions reported.
respondent has family/neighbors/coworkers/friends who are gay, lesbian or bisexual
respondent has family/neighbors/coworkers/friends who are transgender
Force to solve international problems
Warmth rating of Asian-Americans
Warmth rating of Joe Biden after the election
Warmth rating of Joe Biden before the election
Warmth rating of big business
Warmth rating of Black Lives Matter
Warmth rating of Black people
Warmth rating of Christian fundamentalists
Warmth rating of Christians
Warmth rating of congress
Warmth rating of conservatives
Warmth rating of the Democratic Party
Warmth rating of Federal Bureau of Investigation (FBI)
Warmth rating of feminists
Warmth rating of gay men and lesbians
Warmth rating of Gretchen Whitmer
Warmth rating of Kamala Harris after the election
Warmth rating of Kamala Harris before the election
Warmth rating of Hispanics
Warmth rating of illegal immigrants
Warmth rating of Jews
Warmth rating of Josh Shapiro
Warmth rating of labor unions
Warmth rating of liberals
Warmth rating of Make America Great Again (MAGA)
Warmth rating of Mark Kelly
Warmth rating of Muslims
Warmth rating of National Rifle Association (NRA)
Warmth rating of Planned Parenthood
Warmth rating of police
Warmth rating of the Republican Party
Warmth rating of Robert Kennedy, Jr.
Warmth rating of Roy Cooper
Warmth rating of rural Americans
Warmth rating of Democratic Senate candidate
Warmth rating of Republican Senate candidate
Warmth rating of transgender people
Warmth rating of Donald Trump after the election
Warmth rating of Donald Trump before the election
Warmth rating of US House candidate that respondent voted for
Warmth rating of US Supreme Court
Warmth rating of J.D. Vance after the election
Warmth rating of J.D. Vance before the election
Warmth rating of Tim Walz after the election
Warmth rating of Tim Walz before the election
Warmth rating of White people
Should gay/lesbian couples be allowed to adopt children or not
What is respondent's gender?
What is respondent's sex?
Does respondent consider themself to be transgender
Do women complaining about discrimination cause more problems
Do women demanding equality seek special favors
respondent femininity scale
respondent masculinity scale
Sexual orientation of respondent
How good a job does House incumbent do in district
Government performance over the last four years
Government action about rising temperatures
Government run by a few big interests or for benefit of all
How widespread corruption is in government
Government responsibility for health care
Should government do more/less about opioid drug addiction
Does government waste much tax money
How much influence do Hispanics have in US politics
How much influence do blacks have in US politics
How much influence do Asians have in US politics
How much influence do whites have in US politics
Whether some groups receive worse treatment than others
Number of guns respondent owns
Kamala Harris trait: really cares
Kamala Harris trait: energetic
Kamala Harris trait: honest
Kamala Harris trait: knowledgeable
Kamala Harris trait: strong leadership
Has any children
Has one or more daughters
Has one or more sons
Does respondent have health insurance
Hispanic ethnicity group
Helpful/harmful if president did not have to worry about congress/courts
Health benefits of vaccinations outweigh risks
respondent concerned about losing health insurance
respondent concerned about paying for health care
Trouble concentrating in past week
Party of respondent's U.S. House vote intention or preference
Party of respondent's U.S. House vote
Party of respondent's U.S. House vote or preference
Is there a working HH landline phone
Anyone in HH belong to labor union
Hunter Biden's laptop showed he made deal with Ukrainian and Chinese businesses
Does respondent have a valid, non-expired passport
Does respondent have a valid, non-expired driver's license
Are immigrants generally good or bad for America's economy
Belief that immigrants increander, sse crime
How important is being American to respondent's identity
How important that more Asians get elected to political office
How important that more blacks get elected to political office
How important that more Hispanics get elected to political office
How important that more LGBT people get elected to political office
How important that a woman be elected president of the US
How important that more women get elected to political office
How important is it for immigrants to adapt to customs/traditions of the US
How important is the following issue: abortion
How important is the following issue: climate change
How important is the following issue: cost of living
How important is the following issue: crime
How important is the following issue: gun policy
How important is the following issue: illegal immigration
How important is the following issue: what is taught in public schools
How important is the following issue: racial inequality
How important is the following issue: US democracy
How important is the following issue: War in Gaza
How important is urban or rural to respondent's identity
How important is being white to respondent's identity
Increase/decrease government spending to help pay for health care
Increasing diversity made US better/worse place to live
Does respondent use Internet at home
Pre/Post Interview Completion Status
How satisfied is respondent with life
Would it be good for society to have more or less government regulation
Events on January 6, 2021 were carried out by pro-Trump protestors or FBI agents
How satisfied or dissatisfied is respondent with current job?
Working now: out of work or laid off in last 6 months
Who was the legitimate winner of the 2020 presidential election
Was Trump or Harris the legitimate winner of the 2024 presidential election
Less or more government
Life experience: has respondent ever been bitten by a shark
Life experience: has respondent gone hunting or fishing in past year
Life experience: does respondent know someone moved to US from another country
Life experience: has respondent used public transportation in past year
Like-dislike rating of the Democratic presidential candidate
Like-dislike rating of the Democratic Party
Like-dislike rating of the Republican presidential candidate
Like-dislike rating of the Republican Party
How likely respondent is to vote
White respondent: what happens to white people will affect respondent's life
Left-right placement of the Democratic Party
Left-right placement of the Republican Party
Respondent's left-right self-placement
How many days in past week discussed politics with family or friends
Whether men or women are better suited to handle an economic crisis
Whether men or women are better suited to handle a pandemic
Interview mode after the election
Interview mode before the election
Fewer problems if there was more emphasis on traditional family values
The world is changing & we should adjust view of moral behavior
Marital status (5 category)
How much discrimination has respondent faced personally because or race/ethnicity
How much larger is income gap today
How much have political differences hurt relationships w/family
How much has political violence increased/decreased compared to 4 yrs ago
Importance of being born in the United States for national identity
Importance of speaking English for national identity
National economy better or worse in last year
Frequency of reading newspapers
Frequency of visiting online news sites
Frequency of watching news on private television
Frequency of watching news on public television
Frequency of listening to news on radio
Frequency of using social media for news
How often bought or boycotted product/service for social/political reasons
How often do police officers use more force than necessary
How often are votes counted fairly
Which party would do a better job handling: crime
Which party better: handling nations economy
Preference for one-party or split-party government
Party ID
Party ID, 3 categories
Has respondent in past 12 months: attend mtg about issue facing community/schools
Has respondent in past 12 months: contacted federal elected official
Has respondent in past 12 months: done any volunteer work
Has respondent in past 12 months: given money to other organization
Has respondent in past 12 months: gotten into a political argument with someone
Has respondent in past 12 months: joined a protest march, rally, or demonstration
Has respondent in past 12 months: posted comment online about political issue
Has respondent in past 12 months: sign internet or paper petition
During past 12 months, respondent or any family members stopped by police
Has respondent ever been arrested
Police treat blacks or whites better
Attention to politics and elections
Interest in politics
How many years in full term for US Senator
On which program does Federal government spend the least
Party with most members in Senate before election
Party with most members in House before election
People in rural areas get too much/too little respect
People in rural areas get more/less from government
People in rural areas have too much/too little influence
president's handling of COVID
Whether respondent voted in a presidential primary or caucus
Choice if presidential election were only Harris and Trump
Recall of 2016 presidential vote choice
presidential vote in 2024
Whether respondent intended to vote for president
For whom does respondent intend to vote for president
Party of respondent's presidential vote intention or preference
presidential vote or preference
Strength of presidential vote preference
Prefer government official who compromises/sticks to principles
Which party would do a better job handling: abortion
Which party better: handling environment
Which party better: handling immigration
Which party would do a better job handling: climate change
Which party would do a better job handling: cost of living
Which party would do a better job handling: illegal immigration
Which party would do a better job handling: what is taught in public schools
Which party contact respondent about campaign
Party identity importance
Respondent 5 Category level of education
Respondent age on Election Day
Does respondent favor/oppose affirmative action in universities
respondent favor/oppose death penalty
respondent occupation status 1 digit
When did respondent register to vote for the first time
respondent self-identified race/ethnicity
Does respondent side more with Israelis or Palestinians
Respondent spouse/partner 5 Category level of education
respondent spouse or partner race/ethnicity
Does respondent think they get more or less than their fair share in life
How does respondent usually vote
When respondent voted in 2024 election
How respondent voted in 2024 election
How often does respondent have concerned feelings for other racial/ethnic groups
How often respondent imagines how they would feel before criticizing other groups
How often respondent feels protective of someone due to race or ethnicity
How often does respondent try to understand perspective of other racial/ethnic groups
Recall of last (2020) presidential vote
Consolidated office-recall score for U.S. Supreme Court Chief Justice Roberts.
Consolidated office-recall score for French president Emmanuel Macron.
Consolidated office-recall score for Russian president Vladimir Putin.
Consolidated office-recall score for Senate Majority Leader Schumer.
Consolidated office-recall score for Speaker of the House Johnson.
Whether citizen referendums should make political decisions
Party registration in state of registration (pre nonvoter)
Whether respondent is registered to vote
Voter registration status
Detailed religious tradition
Major religious tradition
Whether respondent dislikes anything about the Republican Party
Whether respondent likes anything about the Republican Party
Require employers to offer paid leave to parents of new children
SAMPLE: Census region
Sample Type
Position on abortion: Democratic presidential candidate
Position on abortion: Republican presidential candidate
Position on government assistance to blacks scale: Democratic presidential candidate
Position on government assistance to blacks scale: Republican presidential candidate
Position on government assistance to blacks scale: self-placement
Position on defense spending: self-placement
Position on defense spending: Democratic presidential candidate
Position on defense spending: Republican presidential candidate
Position on environment-business tradeoff: Democratic presidential candidate
Position on environment-business tradeoff: Republican presidential candidate
Position on environment-business tradeoff: self-placement
Position on government-private medical insurance scale: Democratic presidential candidate
Position on government-private medical insurance scale: Republican presidential candidate
Position on government-private medical insurance scale: self-placement
Position on guaranteed job-income scale: Democratic presidential candidate
Position on guaranteed job-income scale: Republican presidential candidate
Position on guaranteed job-income scale: self-placement
Position on liberal-conservative: Democratic House candidate
Position on liberal-conservative: Democratic presidential candidate
Position on liberal-conservative: Republican House candidate
Position on liberal-conservative: Republican presidential candidate
Position on liberal-conservative: Democratic party
Position on liberal-conservative: Republican party
Position on liberal-conservative self-placement
Position on spending & services: self-placement
Position on spending & services: Democratic presidential candidate
Position on spending & services: Republican presidential candidate
Need to be more sensitive talking or people too easily offended
How often does respondent self censor
Party of respondent's U.S. Senate vote intention or preference
Should the minimum wage be raised, kept the same, or lowered
SAMPLE: Sample location state postal abbreviation
How would respondent describe social class [EGSS]
How often use Facebook
How often post political content on Facebook
Which social media platforms respondent visited - Facebook [mention]
Which social media platforms respondent visited - Instagram [mention]
Which social media platforms respondent visited - Other [mention]
Number of social media platforms visited.
Which social media platforms respondent visited - Reddit [mention]
Which social media platforms respondent visited - SnapChat [mention]
Which social media platforms respondent visited - TikTok [mention]
Which social media platforms respondent visited - Twitter [mention]
Which social media platforms respondent visited - YouTube [mention]
Whether respondent votes a straight or split ticket
respondent spouse/partner gender
Stereotype: Blacks violent
Stereotype: Whites violent
Stereotype: Asian-Americans hardworking
Stereotype: Asian-Americans violent
Stereotype: Blacks hardworking
Stereotype: Hispanics hardworking
Stereotype: Hispanics violent
Stereotype: Whites hardworking
Whether having a strong leader in government is good
Does respondent talk to friends/family who live in other countries about events in that country
How much is China a threat to the United States
How much is Iran a threat to the United States
How much is Israel a threat to the United States
How much is Japan a threat to the United States
How much is Mexico a threat to the United States
How much is Russia a threat to the United States
Total (household) income
Total (household) income [six category]
Support for banning transgender girls from girls' sports
Have the courts treated Donald Trump fairly or unfairly
Courts treated Donald Trump fairly/unfairly
Manhattan jury that found Trump guilty made right/wrong decision
Donald Trump's campaign colluded with Russian government in 2016
Donald Trump trait: really cares
Donald Trump trait: energetic
Donald Trump trait: honest
Donald Trump trait: knowledgeable
Donald Trump trait: strong leadership
Trust in Congress
How often can you trust the court system to do what is right
Have no say about what government does
Public officials don't care what people think
Politics/government too complicated to understand
How well does respondent understand important political issues
How often trust government in Washington to do what is right
Trust in government
Trust in the judiciary
Trust and confidence in the news media
Trust in political parties
How often can people be trusted
Trust in scientists
Trust in social media
Trust in traditional media
Agreement that respondent understands important political issues
Unemployment better or worse in last year
More or less unemployment in next year
Preferred response to urban unrest
US better or worse than most other countries
Rating of how democratic the United States is
Does respondent usually think of self as a rural or urban person
How confident is respondent about that (vaccines cause autism)
Does most scientific evidence show vaccines cause autism or not
Voting as duty or choice
Whether who people vote for makes a difference
Did respondent encounter any problems voting - difficulty obtaining absentee ballot
Did respondent encounter any problems voting - confusion about ballot or machine
Did respondent encounter any problems voting - concern about identification card
Did respondent encounter any problems voting - issue mailing ballot
Did respondent encounter any problems voting - respondent didn't try to vote
Did respondent encounter any problems voting - none at all
Did respondent encounter any problems voting - other problem
Did respondent encounter any problems voting - registration problem
Number of voting problems reported.
Did respondent encounter any problems voting - difficulty getting to polling place
Did respondent encounter any problems voting - long wait times
Did respondent encounter any problems voting - bad weather
Did respondent encounter any problems voting - work schedule
Satisfaction with how people voted in the election
Whether respondent had already voted early
Did respondent vote for president in 2016 election
Voter turnout in 2024
Agree/disagree - women interpret innocent remarks as sexist
Women seek to gain power by getting control over men
Whether the share of women in Congress is too high or too low
Support for policies to increase women's representation
Working now: had reduction in work hrs or pay cut
Has respondent experienced harassment at work
How confident is respondent about that (world temperatures have risen)
Have world temperatures have risen on average or last 100 years or not
Working now: worry about losing job in near future
Analysis weight for the pre-election survey
Analysis weight for the post-election survey
American National Election Studies. 2024 Time Series Study Full Release.
Generates box plots for visual comparison of interval-level dependent variable's distribution across categories of independent variable. Includes option for weighting observations, modifying colors, variable widths. Box plot can be used to compare values of interval-level dependent variable by categories of an independent variable (a factor). If iv is omitted, the function creates a single-variable box plot.
boxplotC(dv, iv = NULL, w = NULL, data = NULL, main = NULL, xlab = NULL, ylab = NULL, box.col = "gray80", varwidth = TRUE, ivlabs = NULL, printC = FALSE, ...)boxplotC(dv, iv = NULL, w = NULL, data = NULL, main = NULL, xlab = NULL, ylab = NULL, box.col = "gray80", varwidth = TRUE, ivlabs = NULL, printC = FALSE, ...)
dv |
Dependent variable, should be in dataset$var form unless dataset specified in optional data argument. |
iv |
(Optional) Independent variable, should be in dataset$var form unless dataset specified in optional data argument. If omitted or set to |
w |
(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains dv, iv (and w) variables (optional). |
main |
(Optional) Supply custom main label for plot; default uses names of dv and iv (or just dv if |
xlab |
(Optional) Supply custom x-axis label for plot; default uses name of iv when provided, and blank label when |
ylab |
(Optional) Supply y-axis label for plot; default uses name of dv. |
box.col |
(Optional) The name of color to use for box fills. Default is "gray80". Border color follows |
varwidth |
(Optional) Do you want the widths of boxes to be proportional to number of observations in each group? Default is TRUE; set |
ivlabs |
(Optional) A vector of labels for the iv values that are box lablels. |
printC |
(Optional) Do you want to print box plot to .html file in working directory? (Default: FALSE) |
... |
Additional arguments passed to |
Numeric-looking factor or character labels, such as "10" and "20", are interpreted as their displayed numeric values for the dependent variable.
Invisibly returns the bxp_input object used to draw the plot
(class "boxplot"), including computed boxplot statistics by group.
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
Making Box Plots with RCPA4's boxplotC Function 15:12, shows you how to use the RCPA4 Package's boxplotC function to create box plots that show the relationship between an interval-level dependent variables and a categorical independent variable.
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapter 5.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), pp. 53-55. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Graphing Relationships and Describing Patterns, compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site, find datasets for your own research and resources to help with political analysis.
library(RCPA4) # basic usage with variables as vectors boxplotC(dv=anes$ft_rep_party, iv=anes$partyid3) # single-variable box plot boxplotC(dv=anes$ft_rep_party)library(RCPA4) # basic usage with variables as vectors boxplotC(dv=anes$ft_rep_party, iv=anes$partyid3) # single-variable box plot boxplotC(dv=anes$ft_rep_party)
Reports the confidence interval of a sample mean in table and plot. Default is 95% CI but use can raise or lower confidence level.
CImean(x, w = NULL, data = NULL, digits = 3, conf = 95, pop.sd = NULL, printC = FALSE, plot = TRUE, main = NULL, xlab = NULL, xlim = NULL, table = TRUE, ...)CImean(x, w = NULL, data = NULL, digits = 3, conf = 95, pop.sd = NULL, printC = FALSE, plot = TRUE, main = NULL, xlab = NULL, xlim = NULL, table = TRUE, ...)
x |
A numeric variable, should be in dataset$var form unless dataset specified in optional data argument. |
w |
(Optional) Sampling weights of variable (optional), must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains x (and w) variable (optional). |
digits |
(Optional) Number of decimal places reported in result (defaults to 3). |
conf |
(Optional) A single number equal to the desired confidence level (i.e. 95, 99, 90, etc.). Default value is 95 percent confidence level. |
pop.sd |
(Optional) A single number equal to the known population standard deviation of x. This value is rarely know, but if it is, critical values for confidence interval are based on standard normal distribution. |
printC |
(Optional) Do you want results printed to .html file in your working directory? Default is FALSE. Set to TRUE to print results. |
plot |
(Optional) Do you want a plot of the confidence interval? Default is TRUE. |
main |
(Optional) Change the main title of plot. Default title generated from conf, x, and w. |
xlab |
(Optional) Label for x-axis of confidence interval plot. |
xlim |
(Optional) Modify x-axis limits of confidence interval plot. |
table |
(Optional) Do you want the confidence interval table reported? (default: TRUE) |
... |
(Optional) additional arguments passed to |
Returns the confidence interval as a vector of numeric values (the lower and upper bounds).
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
The table argument controls display of the main result tables separately
from headings and informational messages. Set table = FALSE to omit those
tables from console output and HTML output. See the Value section for the
results returned by this function and how to save them for further use.
The printC argument controls HTML output; printC = FALSE does not suppress
console tables. Turning off tables does not turn off plots.
Confidence Intervals for Sample Means with RCPA4's CImean Function 16:16
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapter 8.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), pp. 184-186. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Foundations of Inference, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA4) CImean(anes$r_age_election_day) # using optional w, conf, and data arguments CImean(x=anes$r_age_election_day, w=anes$wt, conf=90) CImean(x=r_age_election_day, data=anes, conf=95)library(RCPA4) CImean(anes$r_age_election_day) # using optional w, conf, and data arguments CImean(x=anes$r_age_election_day, w=anes$wt, conf=90) CImean(x=r_age_election_day, data=anes, conf=95)
Reports the confidence interval of sample proportions in table and plot. Default is 95% CI but use can raise or lower confidence level.
CIprop(x, w = NULL, data = NULL, digits = 3, conf = 95, printC = FALSE, plot = TRUE, main = NULL, xlab = NULL, xlim = NULL, table = TRUE, ...)CIprop(x, w = NULL, data = NULL, digits = 3, conf = 95, printC = FALSE, plot = TRUE, main = NULL, xlab = NULL, xlim = NULL, table = TRUE, ...)
x |
A nominal or ordinal variable (factor), should be in dataset$var form unless dataset specified in optional data argument. |
w |
(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains x (and w) variable. |
digits |
(Optional) Number of decimal places reported in result (defaults to 3). |
conf |
(Optional) A single number equal to the desired confidence level (i.e. 95, 99, 90, etc.). Default value is 95 percent confidence level. |
printC |
(Optional) Do you want results printed to .html file in your working directory? Default is FALSE. Set to TRUE to print results. |
plot |
(Optional) Do you want a plot of the confidence interval? Default is TRUE. |
main |
(Optional) Change the main title of plot. Default title generated from conf, x, and w. |
xlab |
(Optional) Label for x-axis of confidence interval plot. |
xlim |
(Optional) Modify x-axis limits of confidence interval plot. |
table |
(Optional) Do you want the confidence interval table reported? (default: TRUE) |
... |
(Optional) Additional arguments passed to |
Returns a data frame that gives the lower bound, point estimate, and upper bounds of each value of x variable.
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
The table argument controls display of the main result tables separately
from headings and informational messages. Set table = FALSE to omit those
tables from console output and HTML output. See the Value section for the
results returned by this function and how to save them for further use.
The printC argument controls HTML output; printC = FALSE does not suppress
console tables. Turning off tables does not turn off plots.
Confidence Intervals for Sample Proportions with RCPA4's CIprop Function 18:29
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapter 8.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), pp. 184-186. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Foundations of Inference, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA4) CIprop(anes$life_exprnc_know_smn) # using optional w and data arguments CIprop(x=anes$life_exprnc_know_smn, w=anes$wt) CIprop(x=life_exprnc_know_smn, w=wt, data=anes)library(RCPA4) CIprop(anes$life_exprnc_know_smn) # using optional w and data arguments CIprop(x=anes$life_exprnc_know_smn, w=anes$wt) CIprop(x=life_exprnc_know_smn, w=wt, data=anes)
Mean comparison analysis, options for weighted observations and control variable. Also supports several plotting options for basic mean comparisons and controlled mean comparisons. Can conduct single and two-factor analysis of variance (ANOVA) to test differences among multiple means.
compmeansC(dv, iv, w = NULL, z = NULL, data = NULL, digits = 2, compact = FALSE, ivlabs = NULL, zlabs = NULL, anova = FALSE, printC = FALSE, plot = TRUE, main = NULL, xlab = NULL, ylab = NULL, ylim = NULL, plot.ci = FALSE, z.palette = "LightGrays", legend.title = NULL, table = TRUE)compmeansC(dv, iv, w = NULL, z = NULL, data = NULL, digits = 2, compact = FALSE, ivlabs = NULL, zlabs = NULL, anova = FALSE, printC = FALSE, plot = TRUE, main = NULL, xlab = NULL, ylab = NULL, ylim = NULL, plot.ci = FALSE, z.palette = "LightGrays", legend.title = NULL, table = TRUE)
dv |
Dependent variable, should be in dataset$var form unless dataset specified in optional data argument. |
iv |
Independent variable, should be in dataset$var form unless dataset specified in optional data argument. |
w |
(Optional) Sampling weights of variable (optional), must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
z |
(Optional) Control variable, must be a factor; should be in dataset$z form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains dv, iv (and w) variables (optional). |
digits |
(Optional) The number of decimal places reported in result (defaults to 2). |
compact |
(Optional) Do you want compact version of controlled mean comparison table with N and Std. Dev. values omitted? Default is FALSE. Compact display only available for controlled comparisons. |
ivlabs |
(Optional) A vector of names for the independent variable's values (to abbreviate the mean comparison table's row labels and iv labels on plots) |
zlabs |
(Optional) A vector of names for the control variable's values (to abbreviate a controlled mean comparison table's column labels and z variable's labels on plots) |
anova |
(Optional) Do you want to conduct analysis of variance (ANOVA)? Default is FALSE. |
printC |
(Optional) Do you want results printed to .html file in your working directory? Default is FALSE. Set to TRUE to print results. |
plot |
(Optional) Do you want a plot of the means? Default is TRUE (makes a bar plot). Additional options:
|
main |
(Optional) Main label for plot, if missing, default main title generated. |
xlab |
(Optional) x-axis label for plot, if missing, default label generated using iv name. |
ylab |
(Optional) y-axis label for plot, if missing, default label generated using dv name. |
ylim |
(Optional) Range of y-axis values on plot. |
plot.ci |
(Optional) Do you want vertical 95 percent confidence intervals added to line plot of means? Default is FALSE. Only works when |
z.palette |
(Optional) For bar and line charts with control variables (z), the name of HCL color palette to use. Default is "LightGrays". See |
legend.title |
(Optional) Customize title of legend on plot used for controlling comparisons. |
table |
(Optional) Do you want mean comparison table(s) reported? (default: TRUE) |
Returns an augmented mean comparison table as a matrix of values.
Auxiliary tables are available via [[ (for example
out[["anova_table"]] or out[["controlled_panel_tables"]]).
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
The table argument controls display of the main result tables separately
from headings and informational messages. Set table = FALSE to omit those
tables from console output and HTML output. See the Value section for the
results returned by this function and how to save them for further use.
The printC argument controls HTML output; printC = FALSE does not suppress
console tables. Turning off tables does not turn off plots.
At least one of table or plot must be enabled. When using table = FALSE,
keep a valid plot enabled.
Make Mean Comparisons with RCPA4's compmeansC Function 13:20, shows you how to use the RCPA4 Package's compmeansC function to compare values of an interval-level dependent variable across categories of an independent variable.
Making Controlled Mean Comparisons with RCPA4's compmeansC Function 25:46
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapters 4, 5, 7, 10.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), pp.85-97, 150-156. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Making Comparisons, Graphing Relationships and Describing Patterns, Making Controlled Comparisons, and Chi-Square Test and Analysis of Variance, compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA4) compmeansC(dv=anes$ft_rep_party, iv=anes$party_id, plot=FALSE) # basic usage with a plot compmeansC(dv=anes$ft_rep_party, iv=anes$party_id, w=anes$wt, plot=TRUE) # basic usage: data argument used compmeansC(dv=infant_mortality, iv=region, data=world, plot=FALSE) # with weights and z variable compmeansC(dv=anes$ft_rep_party, iv=anes$party_id, w=anes$wt, z=anes$gender_s_sex, plot="line") compmeansC( dv=anes$ft_gay_men_lesbians, iv=anes$gender_s_sex, z=anes$partyid3, compact=TRUE, plot=TRUE )library(RCPA4) compmeansC(dv=anes$ft_rep_party, iv=anes$party_id, plot=FALSE) # basic usage with a plot compmeansC(dv=anes$ft_rep_party, iv=anes$party_id, w=anes$wt, plot=TRUE) # basic usage: data argument used compmeansC(dv=infant_mortality, iv=region, data=world, plot=FALSE) # with weights and z variable compmeansC(dv=anes$ft_rep_party, iv=anes$party_id, w=anes$wt, z=anes$gender_s_sex, plot="line") compmeansC( dv=anes$ft_gay_men_lesbians, iv=anes$gender_s_sex, z=anes$partyid3, compact=TRUE, plot=TRUE )
Given two or more numeric variables, correlateC reports Pearson's r, along with inferential statistics (if requested), works with sampling weights. If more than two x variables are supplied, the function calculates Pearson's r values using pairwise complete observations (as opposed to limiting analysis to observations complete on all variables).
correlateC(x, w = NULL, data = NULL, digits = 3, stats = FALSE, printC = FALSE, plot = FALSE, jitter = FALSE, table = TRUE, ...)correlateC(x, w = NULL, data = NULL, digits = 3, stats = FALSE, printC = FALSE, plot = FALSE, jitter = FALSE, table = TRUE, ...)
x |
A list of variables for correlation analysis, variables must be numeric. Should be entered as list(dataset$var1, dataset$var2, dataset$var3 ... ) form unless dataset specified in optional data argument. |
w |
(Optional) Sampling weights variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains x (and w) variable (optional). |
digits |
(Optional) Number of decimal places reported in result (defaults to 3). |
stats |
(Optional) Do you want the inferential statistics (standard errors, t-statistics, and P-values)? Default is FALSE. Set to TRUE for inferential statistics. |
printC |
(Optional) Do you want results printed to .html file in your working directory? Default is FALSE. Set to TRUE to print results. |
plot |
(Optional) Do you want scatterplot(s)? Default is FALSE. |
jitter |
(Optional) Do you want scatterplot pointed jittered? By default, points jittered when there are more than 500 observations, but you can set this arguments to TRUE/FALSE to override the default. |
table |
(Optional) Do you want correlation table(s) reported? (default: TRUE) |
... |
(Optional) Additional arguments passed to the internal weighted correlation helper. |
Correlations are computed internally with optional weights and pairwise-complete handling for multivariate input.
Returns the coefficients of correlation among x variables; if stats=TRUE, inferential statistics returned in tables as well.
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
The table argument controls display of the main result tables separately
from headings and informational messages. Set table = FALSE to omit those
tables from console output and HTML output. See the Value section for the
results returned by this function and how to save them for further use.
The printC argument controls HTML output; printC = FALSE does not suppress
console tables. Turning off tables does not turn off plots.
At least one of table or plot must be enabled. When using table = FALSE,
keep a valid plot enabled.
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapter 11.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), pp. 240-244. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Correlation and Bivariate Regression, compiled by Barry C. Edwards.
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA4) correlateC(x=list(prochoice_percent, stateleg_women), data=states, plot=FALSE) # with weighted observations and inferential statistics correlateC(x=list(anes$ft_rep_party, anes$ft_trump_pre, anes$ft_dem_party, anes$ft_biden_pre), w=anes$wt, stats=TRUE)library(RCPA4) correlateC(x=list(prochoice_percent, stateleg_women), data=states, plot=FALSE) # with weighted observations and inferential statistics correlateC(x=list(anes$ft_rep_party, anes$ft_trump_pre, anes$ft_dem_party, anes$ft_biden_pre), w=anes$wt, stats=TRUE)
This is a workhorse function for analyzing the relationship between two variables measured at the nominal or ordinal-level (factors). Basic output is a cross-tabulation with column percentages and counts. Options include weighting observations, adding control variable for controlled cross-tabulation, several plotting options, conducting Chi-Square test of independence, and measuring strength of association.
crosstabC(dv, iv, w = NULL, z = NULL, data = NULL, digits = 2, compact = FALSE, dvlabs = NULL, ivlabs = NULL, zlabs = NULL, chisq = FALSE, lambda = FALSE, somers = FALSE, cramers = FALSE, printC = FALSE, plot = TRUE, plot.response = NULL, main = NULL, xlab = NULL, ylab = NULL, z.palette = "LightGrays", legend.title = NULL, table = TRUE)crosstabC(dv, iv, w = NULL, z = NULL, data = NULL, digits = 2, compact = FALSE, dvlabs = NULL, ivlabs = NULL, zlabs = NULL, chisq = FALSE, lambda = FALSE, somers = FALSE, cramers = FALSE, printC = FALSE, plot = TRUE, plot.response = NULL, main = NULL, xlab = NULL, ylab = NULL, z.palette = "LightGrays", legend.title = NULL, table = TRUE)
dv |
Dependent variable, should be in dataset$var form unless dataset specified in optional data argument. Should be a nominal or ordinal-level variable. |
iv |
Independent variable, should be in dataset$var form unless dataset specified in optional data argument. Should be a nominal or ordinal-level variable. |
w |
(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
z |
(Optional) Control variable, must be a facttor; should be in dataset$z form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains dv, iv (and w) variables. |
digits |
(Optional) Number of decimal places reported in result (defaults to 2). |
compact |
(Optional) Do you want compact display of cross-tabulation with row subtotals omitted? Default is FALSE. |
dvlabs |
(Optional) A vector of names for the dependent variable's values (to abbreviate the cross-tabulation's row labels and dv labels on plots) |
ivlabs |
(Optional) A vector of names for the independent variable's values (to abbreviate the cross-tabulation's column labels and iv labels on plots) |
zlabs |
(Optional) A vector of names for the control variable's values (to abbreviate the controlled cross-tabulation's column labels and z variable labels on plots) |
chisq |
(Optional) Do you want to conduct Chi-Square Test? If z argument specific, Chi-Square Test conducted on dv-iv relationship for each value of z. |
lambda |
(Optional) Do you want Lambda reported? If z argument specified, Lambda reported for dv-iv relationship for each value of z. |
somers |
(Optional) Do you want Somers' d reported? If z argument specific, Somers' D reported for dv-iv relationship for each value of z. |
cramers |
(Optional) Do you want Cramer's V reported? If z argument specific, Cramer's V reported for dv-iv relationship for each value of z. |
printC |
(Optional) Do you want to print cross-tabulation and plot (if plot is used) to .html file in working directory? (default: FALSE) |
plot |
(Optional) Do you want a plot of the cross-tabulation? Default is TRUE (and makes a bar plot). Other plot options:
|
plot.response |
(Optional) The dv value to be summarized on plot. To combine and plot multiple dv values, use transformC and create dummy variable to be plotted. Set |
main |
(Optional) Main label for plot |
xlab |
(Optional) x-axislabel for plot |
ylab |
(Optional) y-axis label for plot |
z.palette |
(Optional) For bar and line plots with control variables (z), the name of HCL color palette to use. Default is "LightGrays". See |
legend.title |
(Optional) Title for legend shown if plot used with z argument. |
table |
(Optional) Do you want cross-tabulation and statistics tables reported? (default: TRUE) |
Returns an augmented cross-tabulation matrix. Auxiliary tables are
available via [[ (for example out[["chisq_table"]] or
out[["association_table"]]).
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
The table argument controls display of the main result tables separately
from headings and informational messages. Set table = FALSE to omit those
tables from console output and HTML output. See the Value section for the
results returned by this function and how to save them for further use.
The printC argument controls HTML output; printC = FALSE does not suppress
console tables. Turning off tables does not turn off plots.
At least one of table or plot must be enabled. When using table = FALSE,
keep a valid plot enabled.
Create Cross-Tabulations to Make Comparisons with RCPA4's crosstabC Function 13:31
Plots for Cross-Tabulations with RCPA4's crosstabC Function 29:51
Making Controlled Comparisons with RCPA4's crosstabC Function 28:34
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapters 4, 5, 7, 10.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), pp.85-97, 150-156, 215-231. ISBN-13: 978-1506379616; ISBN-10: 150637961.
Tutorials & Resources for Making Comparisons, Graphing Relationships and Describing Patterns, Making Controlled Comparisons, and Chi-Square Test and Analysis of Variance, compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA4) crosstabC(dv=anes$r_favor_opps_death, iv=anes$partyid3) # with optional w, data, chisq, somers arguments crosstabC(dv=r_favor_opps_death, iv=partyid3, w=wt, data=anes, chisq=TRUE, somers=TRUE) # example with optional w, data, z, and plot="line" arguments crosstabC(dv=r_favor_opps_death, iv=partyid3, w=wt, data=anes, z=gender_s_sex, plot="line")library(RCPA4) crosstabC(dv=anes$r_favor_opps_death, iv=anes$partyid3) # with optional w, data, chisq, somers arguments crosstabC(dv=r_favor_opps_death, iv=partyid3, w=wt, data=anes, chisq=TRUE, somers=TRUE) # example with optional w, data, z, and plot="line" arguments crosstabC(dv=r_favor_opps_death, iv=partyid3, w=wt, data=anes, z=gender_s_sex, plot="line")
A dataset with variables about students who participated in an experiment. This dataset is used to demonstrate application of R to political analysis. See book Appendix for variable names and descriptions.
A data frame with 171 rows and 14 variables.
Unique identification number for each subject
Name of condition subject was assigned to
Did subject watch debate on TV?
Number of correct answers on five-question quiz about the debate
Is subject Catholic?
Which candidate do you agree with on policy issues?
Which candidate has more integrity?
Which candidate is the more effective leader?
Which candidate has more empathy?
Is respondent a sophomore?
Which candidate won the debate?
Self-reported partisan identification
Self-reported political ideology
Subject's gender
Jamie Druckman. See Appendix of printed textbook for further information.
Generates a table of descriptive statistics for variable(s) specified with x argument, displaying it by default. Works with variables measures at any level but output varies with level of measurement (e.g. you won't get standard deviation for a nominal variable). Character values are analyzed as categorical factors; the function does not convert variables to numeric or ordered classes, but provides class-specific guidance after reporting results. Option for weighting observations.
describeC(x, w = NULL, data = NULL, digits = 3, printC = FALSE, table = TRUE)describeC(x, w = NULL, data = NULL, digits = 3, printC = FALSE, table = TRUE)
x |
A variable or list of variables, should be in dataset$var form unless dataset specified in optional data argument. |
w |
(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains x (and w) variable. |
digits |
(Optional) Number of decimal places reported in result (defaults to 3). |
printC |
(Optional) Do you want to print table of descriptive statistics to .html file in working directory? (default: FALSE) |
table |
(Optional) Display the descriptive-statistics table? Defaults to
|
Invisibly returns a table of descriptive statistics, including when
table = FALSE. Assign the function call to an object to store the results.
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
The table argument controls display of the main result tables separately
from headings and informational messages. Set table = FALSE to omit those
tables from console output and HTML output. See the Value section for the
results returned by this function and how to save them for further use.
The printC argument controls HTML output; printC = FALSE does not suppress
console tables. Turning off tables does not turn off plots.
With table = FALSE, the table and its heading are omitted and no HTML
output is written, even if printC = TRUE. Class-specific informational
messages can still occur; use suppressMessages() to suppress those too.
Generate Descriptive Statistics with RCPA4 Package's describeC Function 17:40
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapter 2.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), pp. 39-55. ISBN-13: 978-1506379616; ISBN-10: 150637961.
Tutorials & Resources for Descriptive Statistics, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA4) # descriptive statistics for qualitative variables describeC(x=world$region) # store results without displaying the table statistics <- describeC(x=world$infant_mortality, table=FALSE) # descriptive statistics for numeric variable describeC(x=world$infant_mortality) # describe multiple variables in list, with optional w argument describeC(x=list(anes$feel_angry, anes$appr_cong_hndl_its), w=anes$wt)library(RCPA4) # descriptive statistics for qualitative variables describeC(x=world$region) # store results without displaying the table statistics <- describeC(x=world$infant_mortality, table=FALSE) # descriptive statistics for numeric variable describeC(x=world$infant_mortality) # describe multiple variables in list, with optional w argument describeC(x=list(anes$feel_angry, anes$appr_cong_hndl_its), w=anes$wt)
Generates a frequency distribution table and bar chart to describe the distribution of variable values. Supports optional case weights.
Includes cumulative percents for ordered factors and for numeric variables
(treating numeric values as ordered categories), except when x has only
two values.
freqC(x, w = NULL, data = NULL, digits = 2, rowlabs = NULL, printC = FALSE, plot = TRUE, main = NULL, xlab = NULL, ylab = NULL, bar.col = "gray80", ylim = NULL, table = TRUE, ...)freqC(x, w = NULL, data = NULL, digits = 2, rowlabs = NULL, printC = FALSE, plot = TRUE, main = NULL, xlab = NULL, ylab = NULL, bar.col = "gray80", ylim = NULL, table = TRUE, ...)
x |
The variable to be analyzed. If dataset not specified with data argument, should be a vector in form dataset$var. |
w |
(Optional) Sample weights (must be numeric if used), If dataset not specified with data argument, should be in form dataset$weighvar |
data |
(Optional) Name of dataset that contains x (and w) variable. |
digits |
(Optional) Number of digits to display after decimal point (default=2). |
rowlabs |
(Optional) Vector specifying custom text for labeling table rows and chart bars. The rowlabs vector must correspond to x variable's levels (if the variable has five levels, rowlabs must be length 5). Useful when default value labels are too long. |
printC |
(Optional) Do you want to print frequency distribution table and bar chart (if plot is used) to .html file in working directory? (default: FALSE) |
plot |
(Optional) Do you want a bar chart? (default set to TRUE) |
main |
(Optional) Main title of bar chart. |
xlab |
(Optional) The x-axis label of bar chart. |
ylab |
(Optional) The y-axis label of bar chart. |
bar.col |
(Optional) The name of color to use for bars. Default is "gray80". |
ylim |
(Optional) y-axis range for bar chart. If omitted, upper bound is set to the next multiple of 10 above the largest percent in table rows (excluding the Total row). |
table |
(Optional) Do you want the frequency distribution table reported? (default: TRUE) |
... |
(Optional) Additional arguments passed to |
Invisibly returns a frequency distribution table (data frame) with
numeric frequencies and percentages. The digits argument controls display
formatting, not stored numeric values.
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
The table argument controls display of the main result tables separately
from headings and informational messages. Set table = FALSE to omit those
tables from console output and HTML output. See the Value section for the
results returned by this function and how to save them for further use.
The printC argument controls HTML output; printC = FALSE does not suppress
console tables. Turning off tables does not turn off plots.
At least one of table or plot must be enabled. When using table = FALSE,
keep a valid plot enabled.
Make Frequency Distribution Tables and Bar Charts with RCPA4 Package's freqC Function 15:33
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapter 2.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), pp. 39-55. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Descriptive Statistics, compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA4) # unordered factors freqC(x=region, data=world) # ordered factors freqC(x=threat_china, w=wt, data=anes)library(RCPA4) # unordered factors freqC(x=region, data=world) # ordered factors freqC(x=threat_china, w=wt, data=anes)
If you don't complete file argument, you will be prompted to select one. Supports common dataset file formats, including CSV, Stata, SPSS, native R, and SAS files. It previews imported data and asks you to confirm before returning a data frame. You must assign this returned object to a name to work with it. Native R files with multiple objects are returned as a named list. If getC doesn't support a file type, it suggests another function or package when possible.
getC(file = NULL, confirm = TRUE, ...)getC(file = NULL, confirm = TRUE, ...)
file |
(Optional) Local path or URL of the file you want to load into your R session; if you do not specify a file, you will be prompted to select one. |
confirm |
(Optional) Do you want to confirm getting file before function results returned? (default: TRUE) |
... |
(Optional) Additional arguments passed to loading function |
A .sas7bdat file contains the SAS dataset. If it has a companion .sas7bcat catalog file, that catalog may supply value labels. Catalogs commonly have the same file name as the data file but a .sas7bcat extension. Provide its path with catalog_file, for example getC("survey.sas7bdat", catalog_file="survey.sas7bcat"). Files compressed with .gz, .bz2, or .xz are supported when their underlying file extension is supported, such as .csv.gz or .dta.gz.
Dataset specified in file argument as a data frame. Native R files containing multiple objects return a named list. You must assign the returned object to a name to work with it.
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
Use confirm = FALSE to skip the data preview and confirmation prompt.
File-selection and other informational messages are controlled separately
by suppressMessages(). To import a specified file without headings,
preview output, or informational messages, set RCPA4.verbose = FALSE and
use suppressMessages(getC(file, confirm = FALSE)).
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapter 15.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), pp. 321-327. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Doing Your Own Political Analysis, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA4) # basic call will prompt user to choose file if (interactive()) { getC() }library(RCPA4) # basic call will prompt user to choose file if (interactive()) { getC() }
A student-friendly subset of the 2024 General Social Survey. This dataset is used to demonstrate application of R to political analysis. See book Appendix for variable names and descriptions.
A data frame with 3309 rows and 365 variables.
Respondent identification number
Abortion allowed for any reason
Abortion allowed for serious birth defect
Abortion allowed if woman's health is endangered
Abortion allowed if married woman wants no more children
Abortion allowed if woman cannot afford child
Abortion allowed if pregnancy resulted from rape
Abortion allowed if woman is not married
People are generally accepting
Immigrants should adopt American culture
Number of adults age 18 and older in household
Total adults in household, experimental version
Favor preferential hiring of Black applicants
Others act afraid of R
R's age in years
Age at first child's birth
Importance of American ancestry
Belief that America is a better country
Importance of being born in America
Importance of being Christian
Importance of US citizenship
Preference for being a US citizen
Importance of feeling American
Importance of respecting US laws
America should follow its own interests
Ashamed of some aspects of America
Preference for American films on television
Frequency of attending religious services
Number of children under age 6 in household
Ballot assignment
People try to take advantage
Better if others were more like Americans
Political news coverage is biased
View of the Bible
Business profits come at expense of workers
Born in the United States
Can become American if born elsewhere
People can be trusted
Favor or oppose death penalty for murder
Number of children
Total children in household, experimental version
Ideal number of children
Policy on changing official documents
US citizen
Subjective class identification
R's birth cohort year
Allow anti-religionist to teach in college
Fire Communist college teacher
Allow anti-American Muslim cleric to teach
Allow racist to teach in college
Uses a computer
Confidence in military
Confidence in major companies
Confidence in organized religion
Confidence in education system
Confidence in executive branch of federal government
Confidence in banks and financial institutions
Family income in constant dollars
Confidence in US Supreme Court
Confidence in organized labor
Confidence in Congress
Confidence in medical profession
Conflict between ordinary people and elites
Confidence in press
R's income, inflation adjusted
Confidence in scientific community
Importance of military service
Confidence in television
Perceived corruption in public service
Courts too harsh or too lenient
Highest degree earned
Democracy will work in ten years
Democracy worked ten years ago
Democracy works today
Religious denomination
Denomination raised in at age 16
High school diploma, GED, or equivalent
Belief that whites are hurt by affirmative action
Men denied job or promotion due to gender discrimination
Women denied job or promotion due to gender discrimination
R treated with less courtesy or respect
Divorce laws too easy or too difficult
Ever divorced or separated
Support for reparations for descendants of enslaved people
Owns or rents home
Number of household income earners
Current state of the national economy
Years of schooling completed
Government should reduce income differences
Ever worked for at least one year
Rely on experts versus ordinary people
People are fair or take advantage
Number of family generations in household
Afraid to walk alone at night
Mother working does not hurt children
Man works and woman cares for home
Hire and promote women equally
Preferential hiring of women
Family suffers when women work
Women not suited for politics
Preschool children suffer if mother works
Change in R's financial situation
Satisfaction with family income
Whether foreigners should be allowed to buy land
Split questionnaire form assignment
People, not politicians, should decide
Religious fundamentalism
How people get ahead in life
Confidence in existence of God
Standard of living will improve
Number of grandparents born outside US
Favor or oppose legalizing marijuana
Favor or oppose gun permits
Happiness of marriage
General happiness
Self-rated health
Government should aid Black people
People are helpful or selfish
Government should do more or less
Importance for children to help others
Government should improve living standard of poor
Government should help pay for medical care
Support for helping worse off people in America
Household type, condensed
Hispanic origin
Same-sex relations right or wrong
Total number of people in household
Hours R worked last week
R or spouse hunts
R's spouse or partner hunts
Vote choice in 2016 counterfactual
Vote choice in 2020 counterfactual
People should support their country
Immigrants are good for the economy
Immigrants should assimilate
Immigrants increase crime
Treatment of undocumented immigrants
Immigrants bring new ideas and cultures
Immigrants take jobs from natives
Prefer natives over immigrants for benefits
Support for limiting imports into the United States
Government responsibility to reduce inequality
Total family income
Industry code, 2010 classification
International companies harm local business
Could find equally good job
Likely to lose job
Children's standard of living compared to R
Knows someone seeing mental health professional
Left-right political self-placement
Allow incurable patients to die
Number of immigrants allowed into the United States
Support for increasing immigration from Asia
Support for increasing immigration from Latin America
Allow anti-religious book in library
Allow Communist book in library
Allow anti-American Muslim cleric book in library
Allow racist book in library
Life exciting or dull
Neighborhood is half Black
Likelihood of voting in 2024
Number of employees at R's work site
College major
Approve close relative marrying Asian person
Approve close relative marrying Black person
Cohabitation status
Approve close relative marrying Hispanic person
Current marital status
Same-sex couples' right to marry
Marital type classification
Approve close relative marrying White person
Men harm family when focused too much on work
Interview mode
Federal spending on foreign aid
Federal spending on military and defense
Federal spending on childcare assistance
Federal spending on solving problems of big cities
Federal spending on halting rising crime
Federal spending on dealing with drug addiction
Federal spending on improving education system
Federal spending on developing alternative energy
Federal spending on protecting the environment
Federal spending on welfare
Federal spending on protecting national health
Federal spending on improving conditions of Black people
Federal spending on highways and bridges
Federal spending on scientific research
Federal spending on Social Security
Federal spending on space exploration
Frequency of reading newspaper
Missed family occasion for work
Unable to care for sick child or relative
No religion identification
R treated as not smart
Importance for children to be obedient
Importance of always obeying laws
Census occupation code, 2010 classification
Importance of civil disobedience
Speaks language other than English or Spanish
Other language spoken, first response
Each nation should have its own country
Has gun in home
Whether parents were born in United States
Living standard compared to parents
Works full time or part time
Political party affiliation
Importance of never evading taxes
Has telephone
Birth control for teenagers age 14 to 16
Pistol or revolver in home
Approve police verbal abuse
Approve police physical attack
R has no say in government
Government does not care what people think
Approve police preventing escape
Approve police striking suspect
Interest in election campaigns
Approve police questioning murder suspect
Use media for political news
Importance of citizen participation
Politicians talk too much
Liberal-conservative self-placement
R received poorer service in stores or restaurants
Importance for children to be popular
Pornography laws
Has marital partner
Belief in life after death
Frequency of prayer
Bible prayer in public schools
Sex before marriage
Presidential vote recall, 2016
Presidential vote recall, 2020
Occupational prestige score, 2010
Occupational prestige score, threshold method, 2010
Number of children age 6 to 12 in household
Pride in American arts and literature
Pride in how American democracy works
Pride in American economic achievements
Pride in American history
Pride in American political influence worldwide
Pride in American achievements in sports
Black-white inequality due to discrimination
Black-white inequality due to inborn ability
Black-white inequality due to lack of education
Black-white inequality due to lack of effort
Black-white inequality due to upbringing
R's race
Opposite race in neighborhood
Support for open housing law
Self-ranking in society
Donald Trump feeling rating
Challenger one time-series rating
Kamala Harris feeling rating
Challenger two time-series rating
Nikki Haley feeling rating
Challenger three time-series rating
Democratic Party feeling rating
Joe Biden feeling rating
Incumbent time-series rating
MAGA Republicans feeling rating
Republican Party feeling rating
Family income in constant dollars
R's income in constant dollars
Born again experience
Would take additional paid work
Would refuse job promotion
Region of interview
Participation in religious activities
Religious preference
Religion has too much influence in politics
Strength of religious affiliation
Self-identified as religious person
Religious tradition classification
Government should protect minority rights
If rich, would continue working
Rifle in home
R's income
Gun belongs to R
R's relationship to household head
Satisfaction with democracy in America
Satisfaction with financial situation
Satisfaction with job
Occupational socioeconomic index, 2010
Percent with some college in R's occupation
Percent with high income in R's occupation
Public service serves people
R's sex
Sex assigned at birth
Sex education in public schools
Current gender identity
Self-identified sexual orientation
Shotgun in home
Number of siblings
Impact of social media exposure
Evening at bar
Evening with friends
Evening with neighbors
Evening with relatives
Importance of adequate standard of living
Interview conducted in Spanish or English
Favor spanking
Allow anti-religionist to speak
Allow Communist to speak
How well R speaks other language
Allow Muslim cleric preaching hatred to speak
Allow racist to speak
Suicide if incurable disease
Suicide if bankrupt
Suicide if tired of living
Enjoy taking surveys
Federal income tax
Number of children age 13 to 17 in household
Teen sex age 14 to 16
Importance for children to think for themselves
R threatened or harassed
People can be trusted
Hours watching television per day
Unemployed in last ten years
R or spouse is a labor union member
R's spouse or partner is a labor union member
Number of unrelated people in household
Familiarity with USMCA
Belief that United States benefits from USMCA
Years R served in the armed forces
Number of visitors in household
Voted in 2016 election
Voted in 2020 election
Voting problems in US elections
Importance of keeping watch on government
Weeks R worked last year
Presidential vote intention, 2024 pre July 25
Presidential vote intention, 2024 post July 25
Presidential vote intention, time series
Ever widowed
Stereotype of Blacks as rich or poor
Stereotype of Hispanics as rich or poor
Stereotype of whites as rich or poor
Vocabulary test score
Stereotype of Blacks as hard working or lazy
Importance for children to work hard
Stereotype of Hispanics as hard working or lazy
Cut back on work
Stereotype of whites as hard working or lazy
R works for government
R works for a private employer
Self-employed or works for someone else
Labor force status
Belief that Blacks can overcome prejudice without favors
International bodies should enforce environmental rules
Post-stratification weight, adjusted
Post-stratification weight
Sex with someone other than spouse
Watched adult movie last year
Expanded NORC size code
Volunteer response assignment
Number of abortion-access circumstances supported, 0 to 7
Number of circumstances where person has right to suicide, 0 to 3
Support for national spending index, -17 to +17
Social activity index, 0 to 24
Number of circumstances justifying police striking citizen, 0 to 5
Discrimination experience index, 0 to 25
Confidence in institutions index, 0 to 26
Free speech tolerance index, 0 to 12
Political party affiliation, 7 categories
Political party affiliation, 3 categories
General Social Survey, 2024. See Appendix of printed textbook for further information.
Opens an interactive menu with these top-level options:
Show help file for RCPA4 function. Select a core RCPA4 function and display its help file.
Explore RCPA4 datasets and variables. Select an RCPA4 dataset, display its help file, and browse its variables.
Show an example. Select a core RCPA4 function and run its documented example.
Help with plots. Open color, line-type, and plotting-character references, or check graphics support.
Find data. Browse datasets in installed packages or open online sources of political data.
Change RCPA4 package settings. Adjust RCPA4.verbose, RCPA4.slow, and RCPA4.pause_seconds.
Clean working environment. List workspace objects and show commands users can run themselves to remove one, several, or all non-hidden objects.
Reset graphical parameters. Close the active graphics device so later plots use default settings.
Browse chapter resources. Open the supplemental web resources for Getting Started, Chapters 1-15, or Advanced Topics.
helpC(option = NULL)helpC(option = NULL)
option |
(Optional) A top-level menu choice from |
Invisibly returns NULL.
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
The settings menu at helpC(6) displays effective session preferences,
using package defaults for unset options. Viewing and exiting the menu does
not change options. Preferences change only when you select a settings action.
The helpC() menu and prompts remain visible when RCPA4.verbose = FALSE.
Result-table controls are documented separately in each analysis function's
help page.
Option 7 lists non-hidden objects in the global environment and displays
rm(object_name), rm(obj1_name, obj2_name), and rm(list = ls()) as commands
to run at the R console. Replace the placeholder names with your object names.
rm(list = ls()) removes all non-hidden objects in the current environment.
The menu itself does not remove or modify any workspace objects.
In option 5, the installed-package dataset browser displays dataset help
and a utils::data() command to run at the R console. The browser does not
load the selected dataset or modify workspace objects. For entries such as
beaver1 (beavers), the command uses the dataset name in parentheses.
if(interactive()){ helpC() helpC(5) }if(interactive()){ helpC() helpC(5) }
Generates frequency distribution table of binned values and a histogram to describe distribution of variable values.
histC(x, w = NULL, data = NULL, breaks = "Sturges", digits = 2, printC = FALSE, plot = TRUE, main = NULL, xlab = NULL, ylab = "Frequency", bar.col = "gray80", table = TRUE, ...)histC(x, w = NULL, data = NULL, breaks = "Sturges", digits = 2, printC = FALSE, plot = TRUE, main = NULL, xlab = NULL, ylab = "Frequency", bar.col = "gray80", table = TRUE, ...)
x |
The variable to be analyzed. If dataset not specified with data argument, should be a vector in form dataset$var. |
w |
(Optional) Sample weights (must be numeric if used), If dataset not specified with data argument, should be in form dataset$weighvar |
data |
(Optional) Name of dataset that contains x (and w) variable. |
breaks |
(Optional) Specify how to break the x variable into bins. Options include the number of breaks, a vector specifying the breakpoints, or the name of an algorithm that generates breakpoints. Default value is "Sturges" (other algorithms are "Scott" and "FD"). |
digits |
(Optional) Number of digits to display after decimal points (default is 2). |
printC |
(Optional) Do you want the histogram and binned frequencies table printed to working directory? (default: FALSE) |
plot |
(Optional) Do you want the histogram graphic? (default: TRUE) |
main |
(Optional) Customize main title for histogram. |
xlab |
(Optional) Custom label for x-axis of histogram. |
ylab |
(Optional) Custom label for y-axis of histogram. |
bar.col |
(Optional) Color for histogram bars; default is "gray80". |
table |
(Optional) Do you want the binned frequency table reported? (default: TRUE) |
... |
(Optional) Additional arguments passed to the internal wtd histogram helper. |
A frequency distribution table of binned x variable values.
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
The table argument controls display of the main result tables separately
from headings and informational messages. Set table = FALSE to omit those
tables from console output and HTML output. See the Value section for the
results returned by this function and how to save them for further use.
The printC argument controls HTML output; printC = FALSE does not suppress
console tables. Turning off tables does not turn off plots.
At least one of table or plot must be enabled. When using table = FALSE,
keep a valid plot enabled.
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapter 2.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), pp. 39-55. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Descriptive Statistics, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA4) histC(x=states$covid_cases_per1000)library(RCPA4) histC(x=states$covid_cases_per1000)
Logistic regression analysis function with many useful features. Its standard output includes a table of coefficients, table of deviance residuals, and table of estimation information. Options include weighting observations, additional reports on odds ratios, ANOVA, classification table, multiple measures of model fit (including Lambda PRE), and diagnostic plots of residuals.
logregC(formula, w = NULL, data = NULL, digits = 3, orci = FALSE, fit.stats = FALSE, anova = FALSE, classify = FALSE, printC = FALSE, plot.res = FALSE, table = TRUE, simple.factors = TRUE, ...)logregC(formula, w = NULL, data = NULL, digits = 3, orci = FALSE, fit.stats = FALSE, anova = FALSE, classify = FALSE, printC = FALSE, plot.res = FALSE, table = TRUE, simple.factors = TRUE, ...)
formula |
should be in dataset$dv ~ datatset$iv1 + dataset$iv2 unless dataset specified in optional data argument. |
w |
(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains dv, iv (and w) variables. |
digits |
(Optional) Number of decimal places reported in result (defaults to 3). |
orci |
(Optional) Do you want table reporting odds ratios for coefficients with confidence intervals? (default: FALSE) |
fit.stats |
(Optional) Do you want a table of assorted model fit statistics? (default: FALSE) |
anova |
(Optional) Do you want ANOVA table reported? (default: FALSE) |
classify |
(Optional) Do you want a classification table (observed vs predicted outcomes)? (default: FALSE) |
printC |
(Optional) Do you want results printed to .html file in your working directory? Default is FALSE. Set to TRUE to print results. |
plot.res |
(Optional) Do you want a set of diagnostic plots of model residuals? (default: FALSE) |
table |
(Optional) Do you want logistic regression result tables reported? (default: TRUE) |
simple.factors |
(Optional) Treat ordered factors like regular factors in regression models? Default is TRUE. Set to FALSE to use R's current contrast setting for ordered factors. |
... |
(Optional) Additional arguments passed to |
Returns an augmented glm (unweighted models) or svyglm (weighted models)
object. The primary model object is unchanged for standard methods (for example
predict, coef, summary), and auxiliary result tables are available via
[[ (for example fit[["model_fit_table"]]).
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
The table argument controls display of the main result tables separately
from headings and informational messages. Set table = FALSE to omit those
tables from console output and HTML output. See the Value section for the
results returned by this function and how to save them for further use.
The printC argument controls HTML output; printC = FALSE does not suppress
console tables. Turning off tables does not turn off plots.
Logistic Regression Analysis with RCPA4 Package's logregC Function 13:36
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapter 14.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), Chapter 9. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Logistic Regression, compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA4) # basic usage with variable vectors logregC(states$battleground2020 ~ states$vep20_turnout) # with post-estimation analysis logregC(states$battleground2020 ~ states$vep20_turnout, orci=TRUE, fit.stats=TRUE, anova=TRUE, classify=TRUE, plot.res=TRUE) logregC(anes$has_children=="Yes" ~ anes$gender_s_sex + anes$r_age_election_day, w=anes$wt)library(RCPA4) # basic usage with variable vectors logregC(states$battleground2020 ~ states$vep20_turnout) # with post-estimation analysis logregC(states$battleground2020 ~ states$vep20_turnout, orci=TRUE, fit.stats=TRUE, anova=TRUE, classify=TRUE, plot.res=TRUE) logregC(anes$has_children=="Yes" ~ anes$gender_s_sex + anes$r_age_election_day, w=anes$wt)
Prints table or summary of results to a .html file in local
working directory. Converting Console format tables to .html tables helps
users quickly create publication- and presentation-ready tables. The .html
file's name is displayed as Console message.
Current date added to Table.Output.html file name to keep output organized.
You can print output directly from Companion functions using printC=TRUE
argument (where available).
printC(objx, file = NULL)printC(objx, file = NULL)
objx |
A table or data frame. The table must be html-ready, not all
Console output is organized in tables. If objx is not a html-ready table,
|
file |
(Optional) The path/file name for .html output. If not specified, function will output to .html file in your working directory. |
Invisibly returns append metadata used by internal block printers. The formatted objx is outputted to a .html file in working directory.
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapter 1.
library(RCPA4) example.table <- freqC(x=world$vdem_4cat, plot=FALSE) # running printC will generate a .html file in your working directory printC(example.table, file=tempfile(fileext = ".html"))library(RCPA4) example.table <- freqC(x=world$vdem_4cat, plot=FALSE) # running printC will generate a .html file in your working directory printC(example.table, file=tempfile(fileext = ".html"))
Backward-compatible alias for random_names().
random.names(n)random.names(n)
n |
The number of random surnames to be generated. |
A vector of surnames.
Linear regression analysis function with many useful features. Standard output of results includes table of coefficients, table of residuals, and additional model information. Options for weighting observations, analysis of variance (ANOVA), performing post-estimation diagnostic tests, including testing normality of residuals and constant variance, and generating diagnostic plots of residuals.
regC(formula, w = NULL, data = NULL, digits = 3, anova = FALSE, norm.test = FALSE, ncv.test = FALSE, linear.test = FALSE, reset.test = FALSE, outlier.test = FALSE, vif = FALSE, printC = FALSE, plot.res = FALSE, table = TRUE, simple.factors = TRUE, ...)regC(formula, w = NULL, data = NULL, digits = 3, anova = FALSE, norm.test = FALSE, ncv.test = FALSE, linear.test = FALSE, reset.test = FALSE, outlier.test = FALSE, vif = FALSE, printC = FALSE, plot.res = FALSE, table = TRUE, simple.factors = TRUE, ...)
formula |
should be in dataset$dv ~ datatset$iv1 + dataset$iv2 unless dataset specified in optional data argument. If weights are specified using w argument, the formula cannot contain functions or logical statements (all variables in the function must be named in the dataset). |
w |
(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains dv, iv (and w) variables. |
digits |
(Optional) Number of decimal places reported in result (defaults to 3). |
anova |
(Optional) Do you want ANOVA table reporting F-test for all predictors? (default: FALSE) |
norm.test |
(Optional) Test assumption that regression residuals follow normal distribution (default: FALSE) |
ncv.test |
(Optional) Test assumption that regression residuals have constant variance (default: FALSE) |
linear.test |
(Optional) Report results of linearity test? (default: FALSE) |
reset.test |
(Optional) Report results of model specification test? (default: FALSE) |
outlier.test |
(Optional) Test whether outlier observations have outsized leverage on results (default: FALSE) |
vif |
(Optional) Report variance inflation factors to assess multicollinearity? (default: FALSE) |
printC |
(Optional) Do you want to print tables of results (and residuals plots if plot.res=TRUE) to .html file in working directory? (default: FALSE) |
plot.res |
(Optional) |
table |
(Optional) Do you want regression result tables reported? (default: TRUE) |
simple.factors |
(Optional) Treat ordered factors like regular factors in regression models? Default is TRUE. Set to FALSE to use R's current contrast setting for ordered factors. |
... |
(Optional) Additional arguments passed to |
Returns an augmented lm or svyglm object. The primary model object is
unchanged for standard methods (for example residuals, coef, predict),
and auxiliary result tables are available via [[ (for example
fit[["model_fit_table"]]).
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
The table argument controls display of the main result tables separately
from headings and informational messages. Set table = FALSE to omit those
tables from console output and HTML output. See the Value section for the
results returned by this function and how to save them for further use.
The printC argument controls HTML output; printC = FALSE does not suppress
console tables. Turning off tables does not turn off plots.
Bivariate Regression Analysis with RCPA4 Package's regC Function 10:31
Multiple Regression Analysis with RCPA4 Package's regC Function 14:55
Analyzing Regression Residuals with RCPA4 Package's regC Function 12:41
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapters 11, 12, 13.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), pp. 244-271. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Correlation and Bivariate Regression, Multiple Regression, and Analyzing Regression Residuals, compiled by Barry C. Edwards.
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA4) # basic usage regC(states$vep20_turnout ~ states$hs_or_more) # with w and data arguments regC(anes$ft_labor_unions ~ anes$ft_dem_party, w=anes$wt) # multiple IV with some post-estimation tests regC(peace_index ~ vdem_edi_score + hdi, data=world, norm.test=TRUE, ncv.test=TRUE)library(RCPA4) # basic usage regC(states$vep20_turnout ~ states$hs_or_more) # with w and data arguments regC(anes$ft_labor_unions ~ anes$ft_dem_party, w=anes$wt) # multiple IV with some post-estimation tests regC(peace_index ~ vdem_edi_score + hdi, data=world, norm.test=TRUE, ncv.test=TRUE)
Visualize expected sampling distributions for sample statistics. You can plot the probability and cumulative density functions for statistics based on either the normal distribution or a t-distribution.
The sampdistC function also generates the confidence interval (default 95%) for a sample statistic which is useful for obtaining the CI of a summary statistic (when you're not estimating it from the dataset yourself).
sampdistC(stat, se, t.df = NULL, plot.cdf = FALSE, ci = 95, digits = 3, printC = FALSE, table = TRUE)sampdistC(stat, se, t.df = NULL, plot.cdf = FALSE, ci = 95, digits = 3, printC = FALSE, table = TRUE)
stat |
A numeric statistic, the point estimate of a parameter based on a sample of observations, like a sample mean or a sample proportion. |
se |
The standard error of the statistic, must be a positive number. |
t.df |
(Optional) If critical values for sampling distribution should be based on t-distribution (generally true when statistic is a mean), set t.df to the number of degrees of freedom (typically n-1). |
plot.cdf |
(Optional) Do you want to plot the cumulative density function? Default = FALSE (for probability density function). |
ci |
(Optional) Specify desired confidence level for confidence interval as a percentage. Set ci=FALSE to suppress CI table (default: 95) |
digits |
(Optional) Number of digits after decimal to display in CI table (default: 3) |
printC |
(Optional) Do you want to sampling distribution plot to .html file in working directory? (default: FALSE) |
table |
(Optional) Do you want the confidence interval table reported when |
Invisibly returns a data frame (sampdistC_result) containing the CI table
when ci is requested. If ci=FALSE, returns an empty CI-shaped data frame and
stores ci_table=NULL in auxiliary metadata.
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
The table argument controls display of the main result tables separately
from headings and informational messages. Set table = FALSE to omit those
tables from console output and HTML output. See the Value section for the
results returned by this function and how to save them for further use.
The printC argument controls HTML output; printC = FALSE does not suppress
console tables. Turning off tables does not turn off plots.
Viewing Sampling Distributions with RCPA4's sampdistC Function 21:51
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapter 8.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), Chapter 6. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Foundations of Inference, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA4) sampdistC(stat=10, se=1) # based on normal distributions sampdistC(stat=10, se=1, plot.cdf=TRUE) # based on t-distribution with 15 degrees of freedom sampdistC(stat=8, se=2, t.df=15) sampdistC(stat=8, se=2, t.df=15, plot.cdf=TRUE)library(RCPA4) sampdistC(stat=10, se=1) # based on normal distributions sampdistC(stat=10, se=1, plot.cdf=TRUE) # based on t-distribution with 15 degrees of freedom sampdistC(stat=8, se=2, t.df=15) sampdistC(stat=8, se=2, t.df=15, plot.cdf=TRUE)
Returns case-level information in order specified by user. You can sort by additional criteria to break ties. Useful for learning about units of analysis and selecting cases for qualitative research designs.
sortC(id, by, data = NULL, thenby = NULL, descending = TRUE, limit = NULL, digits = 3, confirm = TRUE, printC = FALSE, table = TRUE)sortC(id, by, data = NULL, thenby = NULL, descending = TRUE, limit = NULL, digits = 3, confirm = TRUE, printC = FALSE, table = TRUE)
id |
A variable in the dataset (data) that identfies individual cases, typically the name of states, countries, etc. |
by |
Variable the cases should be sorted by. |
data |
(Optional) Dataset to be sorted. |
thenby |
(Optional) Criteria for sorting cases after sorting with the "by" variable. Useful if many cases tied on first criteria. |
descending |
(Optional) Should the cases be sorted in descending order? By default, set to TRUE. When sorting ordered factors, check that the levels higher numerically correspond to the sort order you have in mind. |
limit |
(Optional) The number of rows to report. If there are many observations to be sorted, you may want to limit output to 5, 10, etc. rows. |
digits |
(Optional) Number of decimal places reported in result (default: 3). |
confirm |
(Optional) If function is going to return long table of results (more than 20 rows), you'll be asked for confirmation (use |
printC |
(Optional) Do you want to print table of sorted observations to to .html file in working directory? (default: FALSE) |
table |
(Optional) Display the sorted-observations table? Defaults to
|
Invisibly returns a data frame of sorted observations, limited to
limit rows when supplied, including when table = FALSE. Assign the
function call to an object to store the results.
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
The table argument controls display of the main result tables separately
from headings and informational messages. Set table = FALSE to omit those
tables from console output and HTML output. See the Value section for the
results returned by this function and how to save them for further use.
The printC argument controls HTML output; printC = FALSE does not suppress
console tables. Turning off tables does not turn off plots.
With table = FALSE, the table and its heading are omitted, the long-table
confirmation prompt is skipped, and no HTML output is written, even if
printC = TRUE. The limit argument still controls the number of rows
returned. With table = TRUE, use confirm = FALSE to bypass confirmation
for a long table. Informational messages remain controlled separately by
suppressMessages().
Sort and View Case-Level Information with the sortC Function 12:22
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapters 2, 6.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), pp. 122-123. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Descriptive Statistics, compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA4) # basic usage sortC(id=states$state, by=states$volunteer_hrs_pc, limit=10, confirm=FALSE) # store sorted results without displaying the table sorted <- sortC(id=states$state, by=states$volunteer_hrs_pc, table=FALSE) # options to limit results and sort in ascending order sortC(id=country, by=gini_index, descending=FALSE, limit=10, data=world) # sort by and thenby sortC(id=country, by=vdem_4cat, thenby=gini_index, descending=c(FALSE, FALSE), data=world, confirm=FALSE) sortC(id=country, by=vdem_4cat, thenby=gini_index, descending=c(FALSE, TRUE), data=world, confirm=FALSE)library(RCPA4) # basic usage sortC(id=states$state, by=states$volunteer_hrs_pc, limit=10, confirm=FALSE) # store sorted results without displaying the table sorted <- sortC(id=states$state, by=states$volunteer_hrs_pc, table=FALSE) # options to limit results and sort in ascending order sortC(id=country, by=gini_index, descending=FALSE, limit=10, data=world) # sort by and thenby sortC(id=country, by=vdem_4cat, thenby=gini_index, descending=c(FALSE, FALSE), data=world, confirm=FALSE) sortC(id=country, by=vdem_4cat, thenby=gini_index, descending=c(FALSE, TRUE), data=world, confirm=FALSE)
A dataset with variables about the 50 states. This dataset is used to demonstrate application of R to political analysis. See book Appendix for variable names and descriptions.
A data frame with 50 rows and 186 variables.
Total abortion ban according to Guttmacher Institute as of July 1, 2026 (1 = yes, 0 = no)
Percentage saying abortion should be legal in all or most cases (PRRI 2025)
Abortion rate per 1,000 women ages 15-44 (2025)
Level of abortion restriction or protection by state (Guttmacher Institute, as of July 1, 2026)
Percentage age 25 or older with a graduate or professional degree (2024 ACS, table B15003)
Apparent alcohol consumption in gallons of ethanol per resident age 14 or older (2023)
Percentage supporting a ban on assault-style rifles (CES 2024)
Percentage attending religious services weekly or more (PRRI 2025)
Percentage age 25 or older with at least a bachelor's degree (2024 ACS, table B15003)
Total ballots counted in the 2024 general election (UF Election Lab)
Battleground in 2020? (Cook Political Report)
Presidential battleground state in 2024 (Ballotpedia; 1 = yes, 0 = no)
Biden two-party vote percentage in 2020 election
Percentage Black alone and not Hispanic or Latino (2024 ACS, table B03002)
Percentage of households with a broadband internet subscription of any type (2024 ACS, table B28002)
Motor-vehicle traffic fatalities per 100,000 population (2024)
Percentage supporting making concealed carry easier (CES 2024)
Percentage of households with only a cellular data internet subscription (2024 ACS, table B28002)
Tax-reported charitable contributions per resident (2022)
Agreement that Christians should exercise dominion over U.S. society (percent; PRRI 2025)
Agreement that America depends on its Christian foundations (percent; PRRI 2025)
Percentage agreeing being Christian is an important part of being truly American (PRRI 2025)
Percentage agreeing U.S. laws should be based on Christian values (PRRI 2025)
Percentage agreeing the U.S. government should declare America a Christian nation (PRRI 2025)
State cigarette excise tax per pack (July 1, 2025)
State cigarette excise tax category based on July 1, 2025 KFF rates
Packs smoked bimonthly per adult (2003)
Number of state climate policies enacted (State Climate Policy Dashboard snapshot, July 10, 2026)
Percentage classified as Christian nationalism Adherents or Sympathizers (PRRI 2025)
Democratic percentage of state's 119th Congress delegation at opening (2025)
Cook PVI score (2025; positive = Republican)
Corporal punishment prohibited in public schools (November 2024; 1 = yes, 0 = no)
Incarcerated population per 100,000 residents (2024)
Population under correctional control per 100,000 residents (2026)
Cumulative reported COVID-19 cases per 1,000 population through May 10, 2023
Cumulative reported COVID-19 deaths per 1,000 population through May 10, 2023
Maximum COVID-19 response stringency index (2020-21)
Mean COVID-19 response stringency index (2020-21)
Percentage completing the original COVID-19 primary vaccination series (May 10, 2023)
Burglary offenses per 100,000 residents (FBI via USAFacts, 2024)
Murder and non-negligent manslaughter offenses per 100,000 residents (FBI via USAFacts, 2024)
Violent plus property crime offenses per 100,000 residents (FBI via USAFacts, 2024)
Property crime offenses per 100,000 residents (FBI via USAFacts, 2024)
Violent crime offenses per 100,000 residents (FBI via USAFacts, 2024)
Does state retain the death penalty? Current as of 2025. From Death Penalty Information Center
Federal defense expenditures per capita (FY2024)
Five-category MAP Democracy Overall Policy classification (December 1, 2025)
MAP Democracy Overall Policy Score (December 1, 2025)
Population per square mile (2024 ACS B01001; 2020 Census TIGER/Line)
Diabetes death rate per 100,000 population (KFF State Health Facts, 2024)
Number of statewide direct-democracy tools available (2025)
Census division (9 different regions of country)
Age-adjusted drug overdose deaths per 100,000 residents (2024)
Employment protections for domestic-violence survivors (0-4; 2024)
Federal earmarks per capita (FY2026)
ACEEE state energy-efficiency score (2025)
Adults reporting fair or poor health (percent; 2024)
People ineligible to vote because of felony rules (2024)
Firearm death rate per 100,000 population (KFF State Health Facts, 2024)
Percentage born outside the United States (2024 ACS, table B05012)
GIFFORDS gun law strength letter grade (2025)
GIFFORDS gun law strength rank (2025; 1 = strongest laws)
Gini index of income inequality (2024 ACS, table B19083)
Percentage of employed civilians working for local, state, or federal government (2024 ACS)
Governor's party: D = Democratic or R = Republican (NCSL 2026)
Active firearm dealers per 100,000 residents (March 2026)
Age-adjusted firearm death rate per 100,000 population (2024)
Everytown Gun Law Strength score (2026)
Age-adjusted firearm homicide death rate per 100,000 population (2024)
Estimated percentage of adults living in a household with a firearm (2016)
Ammo.com ranking of states for gun owners (2026; 1 = most gun-friendly)
Kamala Harris two-party vote percentage in 2024 election
Median household income in 2024 inflation-adjusted dollars (2024 ACS, table B19013)
Percentage Hispanic or Latino of any race (2024 ACS, table B03002)
People experiencing homelessness per 10,000 residents (January 2024)
Percentage of occupied housing units that are owner-occupied (2024 ACS, table B25003)
Percentage of K-12 students homeschooled (2023-24 estimate)
Adults age 25+ with a high school credential (percent; 2024)
Per capita income in 2024 inflation-adjusted dollars
Infant deaths per 1,000 live births (KFF State Health Facts, 2023 vital statistics; Vermont 2022)
Primary method for selecting justices of the state's court of last resort (2026)
State high-court justices selected by contested election (1 = yes)
Percentage age 16 or older in the labor force (2024 ACS, table B23025)
State land area in square miles (2020 Census TIGER/Line state boundaries)
Total Democratic legislative seats across both chambers (NCSL 2026 partisan composition)
Other-party or nonpartisan legislative seats (2026)
Total Republican legislative seats across both chambers (NCSL 2026 partisan composition)
Five-category MAP LGBTQ Equality Overall Policy classification (December 1, 2025)
MAP LGBTQ Equality Overall Policy Score (December 1, 2025)
Percentage favoring laws protecting LGBTQ people from discrimination (PRRI 2025)
Life expectancy at birth in years (KFF State Health Facts using NCHS state life tables, 2022)
State marijuana legal status (2025-2026)
Median age of the state population (2024 ACS, table B01002)
Median monthly gross rent in dollars (2024 ACS, table B25064)
Median value of owner-occupied housing units in dollars (2024 ACS, table B25077)
State adopted ACA Medicaid expansion (1 = adopted, 0 = not adopted; KFF tracker, May 2026)
State minimum wage as of July 1, 2026
NCAJ Attorney Access Index score (2021)
NCAJ Consumer Debt Litigation Index score (2024)
NCAJ Disability Access Index score (2021)
NCAJ Fines and Fees Index score (2022)
National Center for Access to Justice overall Justice Index score (updated 2024)
NCAJ Language Access Index score (2021)
NCAJ Self-Representation Access Index score (2021)
Percentage of households with no internet access (2024 ACS, table B28002)
Estimated percentage of the voting-age population that is noncitizen in 2024 (UF Election Lab)
Percentage of adults with BMI of 30 or higher (KFF State Health Facts, 2024 BRFSS; Tennessee 2023)
Legal online gambling type (July 2026)
Percentage saying online gambling should be legal in all or most cases (PRRI 2025)
Retail opioid prescriptions dispensed per 100 persons (2024)
Percentage of the population age 65 or older (2024 ACS, table B01001)
Percentage of the population ages 18 through 24 (2024 ACS, table B01001)
Percentage of the population ages 18 through 44 (2024 ACS, table B01001)
Total state population (2024 ACS, table B01001)
Percentage increase/decrease in population from 2010 to 2020 (not annualized)
Marijuana laws (as of June 2021). From the National Conference of State Legislatures
Percentage below the poverty level in the past 12 months (2024 ACS, table B17001)
Unintended pregnancy rate per 1,000 women 15-44 (2010). From Guttmacher Institute
Number of private-school-choice program types present (2024; 0-3)
Adults saying abortion should be legal in all or most cases (percent; 2023-24)
Protection of immigrants: ILRC immigration-enforcement score (2024)
Workers commuting by public transportation (percent; 2024)
Census region (4 categories)
Adults saying religion is very important in their lives (percent; 2023-24)
Average Pew religiousness scale score (0-8; 2023-24)
Three-category Pew religiousness scale (2023-24)
Percentage reading religious texts weekly or more (PRRI 2025)
Percentage religiously unaffiliated: atheist, agnostic, or nothing in particular (PRRI 2025)
Renters spending at least 30% of income on rent (percent; 2024)
Percentage of occupied housing units that are renter-occupied (2024 ACS, table B25003)
State has a right-to-work law (2026)
Percentage favoring legal same-sex marriage (PRRI 2025)
Average salary of public school teachers (2016). From the National Education Association
Expenditure per student in average daily attendance (2017). From the National Education Association
Students enrolled per teacher (2016). From the National Education Association
Age-adjusted percentage of adults who currently smoke cigarettes (2024; Tennessee 2023)
Southern state?
Percentage age 5 or older speaking only English at home (2024 ACS, table S1601)
Special-education targeted funding-support index (0-3)
State name
State board of education fully elected (2026; 1 = yes, 0 = no)
Unified state control: Democrat, Split, or Republican; Nebraska is missing (NCSL 2026)
U.S. News & World Report 2025 Best States overall rank
Percentage of four-year-olds enrolled in state-funded pre-K (2023-24)
NIEER state pre-K quality standards score (2023-24; 0-10)
State pre-K spending per enrolled child (2023-24 dollars)
Two-letter postal abbreviation for state name
Percentage of state legislators identified as Black/African American (NCSL, spring 2023)
Democratic share of filled state-legislative seats (percent; 2026)
Democratic seat percentage minus Republican seat percentage (NCSL 2026)
Percentage of state legislators identified as Hispanic/Latino (NCSL, spring 2023)
Other-party share of filled state-legislative seats (percent; 2026)
Rank of state legislative professionalism based on the 2021 Squire Index
Squire Index of state legislative professionalism (2021)
Republican share of filled state-legislative seats (percent; 2026)
Percentage of state legislators who are women (NCSL Women in State Legislatures, 2025)
Number of women state legislators (NCSL Women in State Legislatures, 2025)
Age-adjusted suicide death rate per 100,000 population (2024)
Tax Foundation 2026 State Tax Competitiveness Index score
Largest source of combined state and local tax collections (FY2023)
Teen birth rate per 1,000 females ages 15-19 (2024)
Does the state currently limit state legislators' terms? (1 = yes, 0 = no; NCSL, 2026)
Trump two-party vote percentage in 2020 election
Donald Trump two-party vote percentage in 2024 election
Percentage-point change in VEP turnout from 2020 to 2024 (UF Election Lab)
Rank among the 50 states by 2024 VEP turnout; 1 is highest (UF Election Lab)
Percentage of the population under age 18 (2024 ACS, table B01001)
Percentage of the civilian labor force unemployed (2024 ACS, table B23025)
One party controls both legislative chambers and the governorship (1 = yes, 0 = no; NCSL 2026)
Population without health insurance (percent; 2024)
Population ages 0-64 without health insurance (percent; 2024)
Percentage of employed wage and salary workers who were union members (2025)
Statewide universal free school breakfast and lunch (2025-26; 1 = yes, 0 = no)
Percentage of people experiencing homelessness who were unsheltered (January 2024)
Percentage of the state population living in urban areas (2020 Census, table P2)
Voting-age population in 2024 (UF Election Lab)
2024 general-election turnout as a percentage of the voting-age population (UF Election Lab)
Voting-eligible population turnout (percent; 2020)
Voting-eligible population in 2024 (UF Election Lab)
2024 general-election turnout as a percentage of the voting-eligible population (UF Election Lab)
Percentage of the civilian population age 18 or older who are veterans (2024 ACS, table B21001)
Estimated annual formal-volunteer hours per state resident age 16 or older (2023)
Residents volunteering through an organization (percent; 2023)
Identification-document requirement for in-person voting (NCSL, April 24, 2026)
Percentage White alone and not Hispanic or Latino (2024 ACS, table B03002)
Percentage of workers age 16 or older who usually worked from home (2024 ACS, table B08301)
Data sources vary. See Appendix of printed textbook for further information.
Conducts one and two-sample difference of means tests (t-tests). Options for weighting observations, known population standard deviation, equal or unequal variances, paired observations. Numeric-looking factor or character labels, such as "10" and "20", are interpreted as their displayed numeric values.
testmeansC(x1, x2, w = NULL, data = NULL, dv, iv, digits = 2, var.equal = FALSE, paired = FALSE, pop.sd = FALSE, var.test = FALSE, printC = FALSE, conf = 95, plot = TRUE, main = NULL, xlab = NULL, xlim = NULL, table = TRUE, ...)testmeansC(x1, x2, w = NULL, data = NULL, dv, iv, digits = 2, var.equal = FALSE, paired = FALSE, pop.sd = FALSE, var.test = FALSE, printC = FALSE, conf = 95, plot = TRUE, main = NULL, xlab = NULL, xlim = NULL, table = TRUE, ...)
x1 |
The first variable to be compared (mean of x1 will be compared to mean of x2). Must be numeric variable. Should be in the form dataset$var, unless dataset specified with data argument. |
x2 |
The variable (or number) to which x1 is compared. Should be in the form dataset$var, unless dataset specified with data argument. You can set x2 equal to a number to conduct a one sample means test. For example, to test whether x1 could have population mean of 50, you'd set x2 = 50. |
w |
(Optional) Weights variable (optional). Should be in the form dataset$var, unless dataset specified with data argument. |
data |
(Optional) The dataset that contains x1, x1 and x2, or dv and iv. |
dv |
The dependent variable. Must be numeric variable. Should be in the form dataset$var, unless dataset specified with data argument. |
iv |
The independent variable. Should have two distinct values (like treatment and control). Should be in the form dataset$var, unless dataset specified with data argument. |
digits |
(Optional) Number of digits to report after decimal place, optional (default: 2). |
var.equal |
(Optional) With two-sample tests, do you want to assume equal variances? (default: FALSE) |
paired |
(Optional) With two-sample tests, are the observations paired? (default: FALSE) |
pop.sd |
(Optional) If the population standard deviation is known, you can specify it. |
var.test |
(Optional) If set to TRUE, will test the assumption that two sample variance are equal using an F test. Default is FALSE. The var.test option implemented for both weighted and unweighted analysis. If you are not using sample weights, you can supplement this F test with additional tests such as |
printC |
(Optional) Do you want results printed to .html file in your working directory? Default is FALSE. Set to TRUE to print results. |
conf |
(Optional) Desired confidence level, as percentage (default: 95) |
plot |
(Optional) Do you want a plot of the confidence interval of the difference of means? (default: TRUE) |
main |
(Optional) Main title for plot of confidence interval of difference |
xlab |
(Optional) Label for x-axis of plot of confidence interval of difference |
xlim |
(Optional) A vector (of length 2) specifying the range of the x-axis, useful to zoom in on CI. |
table |
(Optional) Display result tables, including the optional
equal-variance test table? Defaults to |
... |
(Optional) Additional arguments passed to |
Invisibly returns a structured list with stable keys:
descriptive_table, test_stats_table, ci_table, and variance_test_table
(NULL when optional analysis is not computed).
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
The table argument controls display of the main result tables separately
from headings and informational messages. Set table = FALSE to omit those
tables from console output and HTML output. See the Value section for the
results returned by this function and how to save them for further use.
The printC argument controls HTML output; printC = FALSE does not suppress
console tables. Turning off tables does not turn off plots.
Use var.test = TRUE to compute the optional equal-variance test. Its table
is displayed only when table = TRUE. With table = FALSE, the test is
still computed and returned in variance_test_table, but its table is
omitted from console and HTML output. Use var.test = FALSE to skip the test.
Testing Means with RCPA4 Package's testmeansC Function 12:22
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapter 9.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), pp.201-215. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Hypothesis Tests with One and Two Samples, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site, find datasets for your own research and resources to help with the analysis.
library(RCPA4) # one sample test against hypothesized value testmeansC(x1=world$literacy, x2=80) # with x1 and x2 testmeansC(x1=ft_trump_post, x2=ft_vance_post, w=wt, data=anes) # with paired x1 and x2 testmeansC(x1=anes$ft_trump_post, x2=anes$ft_trump_pre, w=anes$wt, paired=TRUE) # with dv and iv testmeansC(dv=anes$ft_big_business, iv=anes$gender_s_sex, w=anes$wt)library(RCPA4) # one sample test against hypothesized value testmeansC(x1=world$literacy, x2=80) # with x1 and x2 testmeansC(x1=ft_trump_post, x2=ft_vance_post, w=wt, data=anes) # with paired x1 and x2 testmeansC(x1=anes$ft_trump_post, x2=anes$ft_trump_pre, w=anes$wt, paired=TRUE) # with dv and iv testmeansC(dv=anes$ft_big_business, iv=anes$gender_s_sex, w=anes$wt)
Difference of proportions test with optional sample weights. Reports P-value of two-tailed significance test. Currently limited to testing one response from one dataset. If you want to compare x1 from dataset1 and x2 from dataset2, you can create new dataframe to test as dv ~ iv where dv is vector of x1 and x2 values and iv is vector identifying the source (i.e. dataset1 and dataset2). If you want to compare different responses, such as "Yes" value for x1 and "Agree" value for x2, you will need to transform one of the variables so they have comparable response values.
testpropsC(x1, x2, w = NULL, data = NULL, dv, iv, digits = 3, response = NULL, printC = FALSE, conf = 95, plot = TRUE, main = NULL, xlab = NULL, xlim = NULL, table = TRUE, ...)testpropsC(x1, x2, w = NULL, data = NULL, dv, iv, digits = 3, response = NULL, printC = FALSE, conf = 95, plot = TRUE, main = NULL, xlab = NULL, xlim = NULL, table = TRUE, ...)
x1 |
A categorical variable |
x2 |
Value or variable to compare x1 against. |
w |
(Optional) Weights variable. |
data |
(Optional) Specify name of dataset (data frame) with x1 and x2 variables (or dv and iv). |
dv |
Dependent variable |
iv |
Independent variable, should have only two unique values. For comparison purposes, group1 will be first level of iv and group2 will be the second level of iv. To change order of groups, you can modify levels(iv). |
digits |
(Optional) Number of digits to report after decimal place, optional (default: 3). |
response |
(Optional) Identify the response value you wish to compare. If not specified, the function will compare first value of the dv (or x1 variable). If you want to group multiple responses together, use transformC to make dummy variable. |
printC |
(Optional) Do you want results printed to .html file in your working directory? Default is FALSE. Set to TRUE to print results. |
conf |
(Optional) Desired confidence level, as percentage (default: 95) |
plot |
(Optional) Do you want a plot of the confidence interval of the difference of proportions? (default: TRUE) |
main |
(Optional) Main title for plot of confidence interval of difference |
xlab |
(Optional) Label for x-axis of plot of confidence interval of difference |
xlim |
(Optional) A vector (of length 2) specifying the range of the x-axis, useful to zoom in on CI. By default, |
table |
(Optional) Do you want summary tables reported? (default: TRUE) |
... |
(Optional) Additional arguments passed to plot function for the CI plot |
Invisibly returns a structured list with stable keys:
descriptive_table, z_test_table, and ci_table
(NULL where optional analysis is not computed).
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
The table argument controls display of the main result tables separately
from headings and informational messages. Set table = FALSE to omit those
tables from console output and HTML output. See the Value section for the
results returned by this function and how to save them for further use.
The printC argument controls HTML output; printC = FALSE does not suppress
console tables. Turning off tables does not turn off plots.
Testing Proportions with RCPA4 Package's testpropsC Function 27:33
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapter 9.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), pp.201-215. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Hypothesis Tests with One and Two Samples, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA4) # one sample test: x1 variable against hypothesized value (of x2) testpropsC(x1=anes$favor_opps_bckgrnd, x2=.500, w=anes$wt, response="Favor a great deal", xlim=c(0, .2)) # two sample test x1 versus x2 testpropsC(x1=has_sons, x2=has_daughters, w=wt, data=anes, response="Yes", xlim=c(-.10, .10)) # test of proportions dv by iv testpropsC(dv=mrtl_stts_5_ctgry, iv=gender_s_sex, w=wt, data=anes, response="Widowed", xlim=c(-.10, 0))library(RCPA4) # one sample test: x1 variable against hypothesized value (of x2) testpropsC(x1=anes$favor_opps_bckgrnd, x2=.500, w=anes$wt, response="Favor a great deal", xlim=c(0, .2)) # two sample test x1 versus x2 testpropsC(x1=has_sons, x2=has_daughters, w=wt, data=anes, response="Yes", xlim=c(-.10, .10)) # test of proportions dv by iv testpropsC(dv=mrtl_stts_5_ctgry, iv=gender_s_sex, w=wt, data=anes, response="Widowed", xlim=c(-.10, 0))
Given a variable x, the transformC function generates and returns a tranformed version of x. For example, transformC can take a variable x and return standardized x, or the log of x.
transformC(type, x, data = NULL, response = NULL, cutpoints = NULL, groups = NULL, confirm = TRUE, ...)transformC(type, x, data = NULL, response = NULL, cutpoints = NULL, groups = NULL, confirm = TRUE, ...)
type |
The type of transformation to be made to x. Options include:
|
x |
The variable to be transformed, a variable that already exists, should be in dataset$var form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains x variable. |
response |
(Optional) For |
cutpoints |
(Optional) For |
groups |
(Optional) For |
confirm |
(Optional) By default, |
... |
(Optional) Additional arguments pass to |
A transformed version of x variable, a vector with the same length as x, unless type="dummy.set" in which case transformC returns a data.frame.
Additional RCPA4 headings are controlled by the session option
RCPA4.verbose, which defaults to TRUE. Use
options(RCPA4.verbose = FALSE) to suppress these headings, or change the
setting through helpC(6). The setting applies for the current R session.
Thee RCPA4.verbose option does not suppress result tables, plots, messages,
warnings, errors, or interactive prompts. The option RCPA4.slow = FALSE
disables the package's optional pauses independently of verbosity.
Use confirm = FALSE to return the transformed variable without the
confirmation prompt or transformation-results heading. Informational
messages about the transformation are controlled separately by
suppressMessages().
Transforming Variables with RCPA4 Package's transformC Function 22:40
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapter 3.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Sage Publications, 2020), pp. 55-64. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Creating and Transforming Variables, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA4) # don't use confirm=FALSE until you've tested the function call transformC("percent.rank", anes$ft_dem_party, confirm=FALSE) transformC("rank", anes$ft_dem_party, confirm=FALSE) transformC("whole", runif(min=0,max=100,n=20), confirm=FALSE)library(RCPA4) # don't use confirm=FALSE until you've tested the function call transformC("percent.rank", anes$ft_dem_party, confirm=FALSE) transformC("rank", anes$ft_dem_party, confirm=FALSE) transformC("whole", runif(min=0,max=100,n=20), confirm=FALSE)
Welcomes users to RCPA4 package for An R Companion to Political Analysis, 4th Edition and provides basic information about using Companion functions and datasets.
welcomeC()welcomeC()
No value returned
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapter 1.
R Tutorials & Resources for Getting Started with R, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
library(RCPA4) # Welcome message from RCPA4 package. welcomeC()library(RCPA4) # Welcome message from RCPA4 package. welcomeC()
A fun, interactive game to practice using R functions. Players must execute functions to make widgets per strict specifications to win the game. The Widget Factory needs your help!
widgetFactory()widgetFactory()
No value returned
Complete Playlist of RCPA4 Package Tutorial Videos, includes video for this function and many more.
Barry C. Edwards and Philip H. Pollock, An R Companion to Political Analysis, 4th Edition (Political Science Data, Forthcoming 2026), Chapter 1.
Tutorials & Resources for Using R for Data Analysis, compiled by Barry C. Edwards
library(RCPA4) # Play the Widget Factory game if (interactive()) { widgetFactory() }library(RCPA4) # Play the Widget Factory game if (interactive()) { widgetFactory() }
A dataset with variables about countries in the world. This dataset is used to demonstrate application of R to political analysis. See book Appendix for variable names and descriptions.
A data frame with 169 rows and 234 variables.
Country numerical code. From Association of Religion Data Archives
Proportion of survey respondents from country reporting that they or member of family paid bribe to legal/judicial system in last year. From Global Corruption Barometer
Proportion of survey respondents from country reporting that they or member of family paid bribe to police in last year. From Global Corruption Barometer
Broadband subscription per 100 people in 2017. From Our World in Data
Number of new corporations registered annually. From World Bank's World Development Indicators
Three-letter abbreviation of country name assigned by International Standards Organization
Numeric country code based on the ISO standard
Percent of GDP spent on education (CIA)
Composition of GDP: Agricultural sector (CIA)
Composition of GDP: Industrial sector (CIA)
Composition of GDP: Service sector (CIA)
Civil war intensity, 2008
Carbon dioxide emissions excluding land-use change and forestry, in metric tonnes of CO2-equivalent per person, 2024.
Total greenhouse gas emissions excluding land-use change and forestry, in metric tonnes of CO2-equivalent per person, 2024.
Renewable energy consumption as a percentage of total final energy consumption.
Ocean Health Index score for waters associated with a coastal country, ranging from 0 to 100.
Whether the country has an ocean or sea coastline.
Long-term average annual precipitation over the country's land area, in millimeters per year.
Forest area as a percentage of total land area.
Renewable internal freshwater resources per person, in cubic meters per year.
Whether the country is a party to the United Nations Convention on the Law of the Sea.
Whether the country is a party to the Convention on Migratory Species.
Whether the country is a party to the Nagoya Protocol on access and benefit sharing.
Whether the country is a party to the BBNJ Agreement on marine biodiversity beyond national jurisdiction.
Colony of what country? (CIA)
Compulsory voting in national elections in 2025, including whether sanctions are enforced. From V-Dem
Confidence in institutions scale (World Values Survey)
Global Peace Index score for 2026, with higher values indicating less peaceful conditions.
Number of internal conflicts between govt and groups in country without intervention from other countries. From UCDP/PRIO Database
Number of internal conflicts between govt and groups in country with intervention from other countries (on one or both sides). From UCDP/PRIO Database
Corporate tax rate. From Heritage Foundation's 2021 Index of Economic Freedom
Corruption perception index. From Transparency International
Country or territory name used in the RCPA4 World Dataset
Number of attempted coups d'etats since 1950. From Jonathan Powell
Number of successful coups d'etats since 1950. From Jonathan Powell
Legal status of death penalty (1 = Abolished, 2 = Abolished Except for Extraordinary Crimes, 3 = Abolished in Practice, 4 = Uses Death Penalty). From Death Penalty Information Center
Public debt as a percentage of GDP. From Heritage Foundation's 2021 Index of Economic Freedom
Percentage of other democracies in region
Percentage of other democracies in region: 5 categories
Average number of members per district. From World Values Survey
Effective number of parliamentary parties
Is chief executive a military officer? 0 = no, 1 = yes. From World Bank's Database of Political Institutions
National political system (0 = Presidential, 1 = Assembly-elected President, 2 = Parliamentary). From World Bank's Database of Political Institutions
Number of years since the last regime transition as of 2018 (Polity)
Measure of global economic competitiveness. From World Economic Forum
Heritage Foundation rating of overall economic freedom. From 2021 Index of Economic Freedom
Heritage Foundation assessment of overall economic freedom. From 2021 Index of Economic Freedom
Average schooling years, female (25+). From Educational Attainment Dataset by Barro and Lee
Percentage of females with no schooling (25+). From Educational Attainment Dataset by Barro and Lee
Average schooling years, male (25+). From Educational Attainment Dataset by Barro and Lee
Percentage of males with no schooling (25+). From Educational Attainment Dataset by Barro and Lee
Average rating of quality of educational system, ranges 1-7 (higher values = better quality). From World Economic Forum
Government effectiveness scale (Kaufmann, 2002)
Level of democracy in 2020, 4 ordinal categories. From Economist Intelligence Unit
Is the country classified by the Economist Intelligence Unit as a full or flawed democracy in 2025?
Economist Intelligence Unit Democracy Index score for 2025, ranging from 0 to 10; higher values indicate stronger democracy.
Average of expert evaluation of integrity of country's electoral system. From Electoral Integrity Project
Were there riots and protest after election? From National Elections Across Democracy and Autocracy
Were there riots and protest before election? From National Elections Across Democracy and Autocracy
Effective number of parliamentary parties: 3 categories
Effective number of parliamentary parties. From World Values Survey
Effective number of parliamentary parties
EU member state as of June 2021 (yes/no)
Inflow of foreign direct investment (in millions of U.S. dollars). From Heritage Foundation's 2021 Index of Economic Freedom
Total fertility rate: average number of births per woman; latest available World Bank value
Freedom House rating of democracy, 3 ordinal categories. From 2021 report
Freedom House aggregate political-rights and civil-liberties score for 2025, ranging from 0 to 100; higher values indicate greater freedom.
Level of Internet freedom in country, 3 ordinal categories (1 = Not Free, 2 = Partly Free, 3 = Free). From Freedom House, 2021 Report on Internet Freedom
Measure of Internet freedom in country in 2021; combines measures of obstacles to access, limits on content, and violations of user rights. Ranges 0 to 100 (with 100 = most freedom). From Freedom House
Ethnic factionalization (Alesina et al., 2003)
Ethnic factionalization, divided into High and Low categories
Level of ethnic fractionalization: 3 categories (Low, Medium, High)
Language factionalization (Alesina et al., 2003)
Religious factionalization (Alesina et al., 2003)
In millions of barrels of oil equivalent. From Michael Ross's Oil and Gas Data, 1932-2014
Annual economic growth rate, 5-year average. From Heritage Foundation's 2021 Index of Economic Freedom
GDP per capita at purchasing power parity in constant 2021 international dollars; latest available World Bank value in July 2026 download
GDP per capita at purchasing power parity, July 2026 World Bank download, grouped into five ordered RCPA categories
Gender empowerment measure, 3 categories. From World Values Survey
UNDP Gender Inequality Index (0 = least inequality, 1 = greatest inequality), 2023
GINI index (of income inequality). Most recent estimates from CIA World Factbook (as of June 2021)
Social globalization measured by personal contacts of citizens, information flows, and cultural proximity. From KOF Index of Globalization
Capacity of state to provide for needy citizens. From Fund for Peace, Fragile States Index
Rating of government integrity. From Heritage Foundation's 2021 Index of Economic Freedom
Government spending (all types) as a percentage of GDP
Measure of the quality of government. From International Country Risk Guide of Political Risk Group
Government Restrictions Index based on 20 indicators of ways that governments restrict religion, including through coercion and force. From Pew Research Center on Global Restrictions of Religion Report, 2016 data
Name of the religion preferred by the government in 2015 (based on multidimensional measure of government favoritism)
Measure of Government Religious Preference in 2015, how strongly government favors one religion over others
Measure of how happy citizens are. From World Happiness Report
Human development index (HDI) value (as of June 10, 2021). Human development dimensions include having long and healthy lives, being knowledgeable, and enjoying a decent standard of living. From UNDP Human Development Report
Percentage of adults ages 15-49 living with HIV.
Number of intentional homicides per 100,000 persons. From UNODC Global Study on Homicide 2013 (where 2012 data missing from report, last reported year used, typically 2011)
Hospital beds per 1,000 people.
Measure of human flight and brain drain from country. From Fund for Peace, Fragile States Index
Whether the country is currently a state party to the Rome Statute of the International Criminal Court (Yes/No)
International migrant stock as a percentage of population; latest available World Bank value
Number incarcerated per 100,000 persons. From World Prison Brief
Income tax rate. From Heritage Foundation's 2021 Index of Economic Freedom
Does country have an independent judiciary? (1 = yes). From Political Constraints Index Dataset
Year of independence (CIA)
Infant deaths before age one per 1,000 live births.
Annual inflation rate. From Heritage Foundation's 2021 Index of Economic Freedom
Percentage of population that uses the Internet (as of 2020 or 2021)
Rating of effectiveness of country's judiciary. From Heritage Foundation's 2021 Index of Economic Freedom
Average rating of judicial independence, ranges 1-7. From World Economic Forum
Property rights index in 2025, ranging from 0 (low) to 1 (high). From V-Dem
Legal origin of commercial code of country (1 = English Common Law, 2 = French Commercial Code, 3 = Socialist/Communist Laws, 4 = German Commercial Code, 5 = Scandinavian Commercial Code). From LaPorta, Lopez de-Silanes, Shleifer, and Vishny (1998)
Measure of quality of country's legal institutions. From the Institutional Quality Dataset
Life expectancy at birth, total years; latest available World Bank value
Life expectancy at birth among females, total years; latest available World Bank value
Life expectancy at birth among males, total years; latest available World Bank value
Literacy rate (CIA)
Does country provide free or subsidized media access for political candidates? (1 = yes) From Institute for Democracy and Electoral Assistance
Does country provide free or subsidized media access for political parties? (1 = yes). From Institute for Democracy and Electoral Assistance
Median age in 2025 from UN World Population Prospects medium projection via Our World in Data
Net migration, immigrants minus emigrants; latest available World Bank value
Are Muslims the predominant religious group?
OECD member state as of June, 2021? (yes/no)
Oil production, in barrels per day (CIA) CIAOIL_P
In metric tons. From Michael Ross's Oil and Gas Data, 1932-2014
Average rating of the impact of organized crime on the economy, ranges 1-7 (lower values = more impact). From World Economic Forum
State of peace in country, 5 ordinal categories. From Visions of Humanity's Global Peace Index 2021 Report
Reversed Global Peace Index score for 2026, with higher values indicating greater peacefulness.
Post-materialism, 3 categories (World Values Survey)
Political terror scale. Ordinal scale from 1-5 of how much government terrorizes country's citizens, with 1 corresponding to very little oppression by government. From Amnesty International
Political terror scale. Ordinal scale from 1 to 5 of how much government terrorizes country's citizens, with 1 corresponding to very little oppression by government. From Human Rights Watch
Polity5 combined democracy-autocracy score for 2018, ranging from -10 for strongly autocratic regimes to +10 for strongly democratic regimes. This is a historical measure; Polity5 has not been updated beyond 2018. Source: Center for Systemic Peace.
Percentage of population ages 0-14; latest available World Bank value
Percentage of population ages 15-64; latest available World Bank value
Percentage of population ages 65 and older; latest available World Bank value
Annual population growth percentage; latest available World Bank value
Percentage of population living in urban areas; latest available World Bank value
Total population; latest available World Bank value
Total population grouped into three ordered RCPA categories using the latest available World Bank value
Population density, people per square kilometer of land area; latest available World Bank value
Percentage of the population below the poverty line
Proportional representation electoral system? From the Institute for Democracy and Electoral Assistance
Measure of freedom of the country's press. Based on Freedom House Freedom of the Press Report 2015, fit to 0-10 range
Measure of freedom of the country's press. From Reporters Sans Frontiers
Protest activity (World Values Survey)
Refugees under UNHCR mandate by country or territory of origin; latest available World Bank value
Measure of impact of population displacement on country. From Fund for Peace, Fragile States Index
Refugees under UNHCR mandate by country or territory of asylum; latest available World Bank value
Regime type. From Cheibub's Democracy Dictatorship dataset
Region name
United Nations region
Largest religion by proportion (UN)
Does country reserve seats in national legislature for any group (e.g., women or young people)? From Inter-parliamentary Union
Freedom of assembly and association, ordinal scale 0-2. From CIRI Human Rights Data Project
Freedom of domestic movement, ordinal scale 0-2. From CIRI Human Rights Data Project
Freedom of foreign travel and emigration in 2025, recoded into three ordered categories. From V-Dem
High-court independence in 2025, recoded into three ordered categories. From V-Dem
Measure of violations of human right and rule of law. From Fund for Peace, Fragile States Index
Freedom of religion in 2025, recoded into three ordered categories. From V-Dem
Freedom of speech, ordinal scale 0-2. From CIRI Human Rights Data Project
Number of international human rights treaties ratified (out of 16 possible). From UNHRC
Women's economic rights, ordinal scale 0-2. From CIRI Human Rights Data Project
Women's political rights, ordinal scale 0-2. From CIRI Human Rights Data Project
Women's social rights, ordinal scale 0-2. From CIRI Human Rights Data Project
Average rating of internet availability in schools, ranges 1-7 (higher values = more extensive). From World Economic Forum
Percentage of labor force that is self-employed. From World Bank's World Development Indicators
Sex ratio at birth, male births per 100 female births; latest available World Bank value
Social Hostilities Index based on 13 indicators of ways in which private individuals and social groups infringe upon religious beliefs and practices. From Pew Research Center on Global Restrictions of Religion Report, 2016 data
Percentage of labor force in the military. From World Bank's World Development Indicators
Total number of people in the military. From World Bank's World Development Indicators
Public expenditure on education as a percentage of GDP (UN)
Domestic general government health expenditure as a percentage of GDP.
Military expenditure as a percentage of GDP; latest available World Bank/SIPRI value
Tariff rate on imports. From Heritage Foundation's 2021 Index of Economic Freedom
Taxes (all forms) as a percentage of gross domestic product. From Heritage Foundation's 2021 Index of Economic Freedom
Measure of the impact of terrorism on the country. From Visions of Humanity
Exports plus imports of goods and services as a percentage of GDP; latest available World Bank value
Predominant religion
Percentage of labor force that is unemployed (available/seeking employment but not employed). From CIA World Factbook (most recent estimates available as of June 2021)
Public expenditure on research and development as a percentage of GDP (UN)
Ratio of female-to-male formal employment rates
Inequality-adjusted income index (2010, UN)
Inequality-adjusted education index (2010)
Union density
Number of verified cases of journalists imprisoned in 2009 (UN)
Adult literacy rate (percentage of population age 15 or older) (UN)
Percentage of the population covered by a mobile phone network (2008, UN)
Adult mortality rate among females, per 1,000 female adults; latest available World Bank value
Adult mortality rate among males, per 1,000 male adults; latest available World Bank value
Daily newspapers per thousand people (2004, UN)
Age-standardized deaths from noncommunicable diseases per 100,000 people.
Projected 2030 population in millions, UN medium scenario via Our World in Data
Per capita remittance inflows in U.S. dollars (2008)
Remittance inflows as a percentage of GDP (2008)
Overall life satisfaction, most recent measure during 2006-2009 (0-10, higher means more satisfied) (UN)
Overall life satisfaction among females, most recent measure during 2006-2009 (UN)
Percentage of employed who are satisfied with their job (UN)
Percentage who are satisfied with their standard of living (UN)
Percentage of the population ages 25 and older with at least secondary education (UN)
Democracy or autocracy in 2025, derived from V-Dem's Regimes of the World classification
Regime type in 2025, ordered from liberal democracy to closed autocracy. From V-Dem
Electoral Democracy Index in 2025, ranging from 0 (low) to 1 (high). From V-Dem
Liberal Democracy Index in 2025, ranging from 0 (low) to 1 (high). From V-Dem
Percent saying religion very important, 3 categories
Economic cost of violence on national economy. Measured as a percentage of GDP. From Visions of Humanity
Turnout of voting age population: average of both presidential and parliamentary elections in 2010s. From the Institute for Democracy and Electoral Assistance
Women as a percentage of the lower or unicameral legislative chamber in 2025. From V-Dem
Year women first enfranchised. From Inter-parliamentary Union
Women's suffrage. From Inter-parliamentary Union
Percentage of lower house of legislature aged 40 years or younger, as of June 2021. From the Inter-parliamentary Union
Participatory Democracy Index in 2025, ranging from 0 (low) to 1 (high). From V-Dem
Deliberative Democracy Index in 2025, ranging from 0 (low) to 1 (high). From V-Dem
Egalitarian Democracy Index in 2025, ranging from 0 (low) to 1 (high). From V-Dem
Judicial constraints on the executive in 2025, ranging from 0 (low) to 1 (high). From V-Dem
Rule of Law Index in 2025, ranging from 0 (low) to 1 (high). From V-Dem
Secure and effective access to justice in 2025, ranging from 0 (low) to 1 (high). From V-Dem
Political Corruption Index in 2025, ranging from 0 (less corruption) to 1 (more corruption). From V-Dem
Freedom of expression and alternative information in 2025, ranging from 0 (low) to 1 (high). From V-Dem
Civil Society Participation Index in 2025, ranging from 0 (low) to 1 (high). From V-Dem
Women's Political Empowerment Index in 2025, ranging from 0 (low) to 1 (high). From V-Dem
Civil Liberties Index in 2025, ranging from 0 (low) to 1 (high). From V-Dem
Physical Integrity Index in 2025, ranging from 0 (low) to 1 (high). From V-Dem
V-Dem model estimate of high-court independence in 2025; higher values indicate greater independence
Property Rights Index in 2025, ranging from 0 (low) to 1 (high). From V-Dem
V-Dem model estimate of freedom of religion in 2025; higher values indicate greater freedom
Freedom of domestic movement and residence in 2025, ranging from 0 (low) to 1 (high). From V-Dem
V-Dem model estimate of freedom of foreign travel and emigration in 2025; higher values indicate greater freedom
Freedom of association for political parties and civil-society organizations in 2025, ranging from 0 (low) to 1 (high). From V-Dem
V-Dem model estimate of equality in access to high-quality basic education in 2025; higher values indicate greater equality
V-Dem model estimate of equality in access to high-quality basic health care in 2025; higher values indicate greater equality
National gender quota for the lower or unicameral legislative chamber in 2025. From V-Dem
V-Dem model estimate of social consensus on major political issues in 2025; higher values indicate less polarization
Maternal deaths per 100,000 live births.
Estimated new and recurrent tuberculosis cases per 100,000 people.
Percentage of adults age 18 and older with a body mass index of 30 or higher, age-standardized.
Percentage of children ages 12-23 months receiving three doses of DPT vaccine.
Household out-of-pocket spending as a percentage of current health expenditure.
Universal Health Coverage service coverage index, ranging from 0 to 100; higher values indicate broader essential-service coverage.
Data sources vary. See Appendix of printed textbook for further information.