NOW AVAILABLE: Essentials of Poltical Analysis 7e | R Companion 4e | SPSS 7e | Stata 5e | Excel 1e 🎵
NOW AVAILABLE: Essentials 7e | R Companion 4e | SPSS 7e | Stata 5e | Excel 1e 🎵
NOW AVAILABLE: Essentials 7e | More Textbooks 🎵

Run R Code Example Online

# 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!")