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
# Explore contents of dataset and variable in dataset
#############################################################
library("poliscidata")
# You need to load the poliscidata package each time at the start of each session/script.
# You should also always set a working directory, but this demo script is running on a remote server.
#############################################################

# Commands to explore an object, such as the NES dataset
cat("Number of rows in NES dataset:\n")
nrow(nes)

cat("\n\nNumber of columns in NES dataset:\n")
ncol(nes)

cat("\n\nDimensions of the NES dataset:\n")
dim(nes)

# Look at info recorded in the first row of the NES dataset.
# These responses come from one of the people who participated in the NES survey.
# To make it easier to read, we can transpose the row into a column with the t() function.

cat("\n\nValues recorded in NES dataset, row 1:\n")
t(nes[1,])
Watch & Learn
thumbnail preview
â–º
i
From Mike Marin (8:45).
 Importing , Checking and Working with Data
thumbnail preview
â–º
i
Video tutorial & demo by Barry Edwards for R Companion to Political Analysis, 3rd Ed. (19:20).
 Viewing Sampling Distributions With RCPA3's SampdistC Function
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