FIND DATA: By Author | Journal | Sites   ANALYZE DATA: Help with R | SPSS | Stata | Excel   WHAT'S NEW? US Politics | Int'l Relations | Law & Courts
   FIND DATA: By Author | Journal | Sites   WHAT'S NEW? US Politics | IR | Law & Courts
Run R Code
About This Page
This page features live demonstrations of the R Statistics Program used for political science research.
  • To run example, click the Run button.
  • To copy example code, click the Copy button.


See More R Demos
Run R Code in Your Web Browser
# Descriptive Statistics for Interval-Level Variable
#############################################################
library("poliscidata")
#############################################################

# The values of interval-level variables are numbers that really mean something.
# The age variable in the GSS dataset is a good example of a interval-level variable.
# The gss$age variable records the age in years of respondents.  Makes sense, right?
# We have the most tools for describing interval-level variables.
cat("Summary Statistics:\n")
describe(gss$age, weights=gss$wtss)

# Describing interval variables is something of an art.  
# Our goal should be to show the appropriate level of detail.  
wtd.hist(gss$age, weight=gss$wtss, main="This level of detail (5 year groups) is better.", col="gray80")

cat("Frequency Distribution Table::\n")
freq(gss$age, gss$wtss, main="Whoa. We probably do not need to plot each age separately!")
Watch & Learn
thumbnail preview
â–º
i
From Jalayer Academy (3:37), another way to generate mean comparison table..
 How to Use Aggregate Function
thumbnail preview
â–º
i
From Andrew Gard (7:29).
 Chi-Squared Functions
MORE VIDEOS: See Video Channels for more political science videos!
LEARN HOW: Watch Lecture Videos for Essentials of Political Analysis, Video Tutorials for R, Stata, SPSS, and Excel