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

library(poliscidata)

# Collapsing numeric variables into roughly equal-sized groups (quantiles)
describe(world$pop_urban)
world$pop_urban.5cat = cut2(world$pop_urban, g=5)

# the next two lines not strictly necessary but should check our work
levels(world$pop_urban.5cat)
freq(world$pop_urban.5cat, plot=F)