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
library(poliscidata)

# We are going to map the thermometer subjects based on their correlations
variableSet = cbind(liberals=nes$ftgr_liberals, feminists=nes$ftgr_feminists, 
                    big_biz=nes$ftgr_bigbus,    military=nes$ftgr_military, 
                    atheists=nes$ftgr_atheists, gays=nes$ftgr_gay,
                    asians=nes$ftcasi_asian,
                    illegal_imm=nes$ftcasi_illegal,
                    supreme_court=nes$ftgr_ussc,
                    muslims=nes$ftgr_muslims,
                    mormons=nes$ftgr_mormons,
                    hillary_clinton=nes$ft_hclinton,
                    blacks=nes$ftcasi_black,
                    democrats=nes$ft_dem,
                    republicans=nes$ft_rep,
                    obama=nes$obama_therm,
                    whites=nes$ftcasi_white,
                    catholics=nes$ftgr_catholics,
                    congress=nes$ftgr_congress,
                    poor=nes$ftgr_poor,
                    rich=nes$ftgr_rich,
                    john_roberts=nes$ftpo_roberts,
                    tea_party=nes$ftgr_tea,
                    unions=nes$ftgr_unions,
                    christians=nes$ftgr_xian,
                    welfare=nes$ftgr_welfare,
                    conservatives=nes$ftgr_cons,
                    working_class=nes$ftgr_working,
                    middle_class=nes$ftgr_middle
                    ) 
# We will focus on the correlations only 
# For simplicity, rounding the results to 2 decimal places
corr_matrix = wtd.cor(variableSet, weight=nes$wt)$correlation

# creating a map 
dist_matrix = 1 - corr_matrix
plot(smacof::mds(dist_matrix, ndim=2), main="Multi-Dimensional Scaling of Feeling Thermometers")
Watch & Learn
thumbnail preview
â–º
i
By James Scott (18:11).
 Getting Started with RStudio
thumbnail preview
â–º
i
(16:42).
 Filepaths - Hidden Necessities!
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