Welcome to POL 051!

POL 051 - Summer Session 1 2026

Haley Daarstad

Welcome

Meet the professor

Headshot of Dr. Mine Çetinkaya-Rundel

Haley Daarstad (she/her)
  • Political Science PhD Candidate
    • Comparative Politics and Methodology
    • Crime, Violence, Behavior, and Gender
  • My Summer Ins:
    • Hockey, Hiking, Iced Tea
  • My Summer Outs:
    • Humidity, Fires, Allergies

Tell Me About you!

  • What is your name?
  • What is your major?
  • What year are you?
  • What is one summer in for you and what is one summer out?

Course learning objectives

  • By the end of this course you will be able to…
    • Analyze real-world data to answer questions about different relationships.
    • Feel comfortable manipulating data in R
    • Craft effective visualizations of patterns in data
    • Draw causal diagrams and identify obstacles to causal claims
    • Understand the basics of regression and uncertainty

Course info

Day Time Location
Lectures Mon, Tue & Wed. 12:10 pm - 1:50 pm Hoagland Hall 168
Discussion/Lab Thu 12:10 pm - 1:50 pm Teaching and Learning Complex 2212
Office Hours Tue 2:00 - 4:00 PM Kerr Hall 569

Course toolkit

  • All materials for this course are free and online. You will do all of your analysis with the open source (and free) programming language R and RStudio.

Activities: Prepare, Participate, Practice, Perform

  • Prepare: Introduce new content and prepare for lectures by completing the readings (and sometimes watching the videos)

  • Participate: Attend and actively participate in lectures and labs, office hours, team meetings

  • Practice: Practice applying statistical concepts and computing with application exercises during lecture, graded for completion

  • Perform: Put together what you’ve learned to analyze real-world data

    Category Percentage
    Application Exercises (Participation) 15%
    Labs 35% (7% x 5)
    Final Project 50%

Final Project

  • Make a Research Question, pick a data set, and do analysis. That is your final project.

  • The goal of the final project is for you to apply the skills you have been learning through out the quarter and apply to real life data to answer a question YOU HAVE MADE.

  • You will be split into teams, I recommend sitting with these teams during lecture and labs.

  • You will have time during lab this Thursday (about 30 minutes) to discuss and write up your project proposal for your group.

    • The project proposal will be due Sunday June 28
  • Learn More on the Project Description page on the course website.

Teams

  • Team assignments
    • Application exercises, labs, and project
    • Anonymous Peer evaluation after completion of Final Project
  • Expectations and roles
    • Everyone is expected to contribute equal effort
    • Everyone is expected to understand all code turned in
    • Individual contribution evaluated by peer evaluation, commits, etc.

Team Assignment

  • What’s the category?

    • I have written down different words that fit under a category. Based on the word you have find the other members of your category.

      • Colors

      • Food

      • Sports

      • Animals

      • Classic Books

    • Introduce yourself to your team and choose a team name and a “team captain” (5 minutes)

      • The “team captain” will be in charge of submitting everything, they are not the leader!!

Support

  • Attend office hours
  • Reserve email for questions that can be answered quickly and timely

Diversity + inclusion

It is my intent that students from all diverse backgrounds and perspectives be well-served by this course, that students’ learning needs be addressed both in and out of class, and that the diversity that the students bring to this class be viewed as a resource, strength and benefit.

  • This is a political science course, and as such we will be discussing political issues. As each of us comes into the section with unique opinions about political issues, there may be disagreements. I insist we discuss our differences with respect, civility, and empathy. Please do your best to keep an open mind about your peers’ perspectives as your peers will expect the same of you.
  • This does not mean you should avoid participating if/when you have an alternative point of view just because you may not wish to provoke an argument. Be bold, and share what you think (respectfully)
    • If I believe any of the discussion is becoming disrespectful or includes hateful or inappropriate speech, I hold the right to end the discussion.

Accessibility

  • If you believe you have a disability requiring an accommodation or would like additional information about the resources available for students with disabilities, please visit the UC Davis Student Disability Center website at sdc.ucdavis.edu.

  • Students must contact me about any accommodations.

  • Outside Resources - The Student Academic Success Center is a campus wide resource assisting students by helping them improve in study skills, academic writing, and other specific topics

Course policies

Late work, waivers, regrades policy

  • If there are circumstances that prevent you from completing a lab or project assignment by the stated due date, you may email me before the deadline to waive the late penalty
    • FINAL PROJECT REPORT IS EXCLUDED FROM THIS
  • Labs may be submitted up to 3 days late. There will be a 5% deduction for each 24-hour period the assignment is late.

Sharing / reusing code policy

  • I am aware that there is a large amount of code is available online, and many tasks may have solutions posted

  • Unless explicitly stated otherwise, this course’s policy is that you may make use of any online resources (e.g. RStudio Community, StackOverflow, etc.) but you must explicitly state where you obtained any code you directly use or use as inspiration in your solution(s).

  • Any recycled code that is discovered and is not explicitly cited will be treated as plagiarism, regardless of source.

Policy on AI

AI is NOT allowed for usage in this classroom.

  • You may not use artificial intelligence tools such as ChatGPT, Gemini, Claude, Grok, etc. to complete academic work

Academic Integrity

  • Cheating and plagiarism will be evaluated and disciplined according to University policy.

  • For information on academic integrity, please read: http://cai.ucdavis.edu/aip.html.

  • You are responsible for understanding and following all aspects of University policy on academic integrity; ignorance is not an excuse.

Most importantly!

Ask if you’re not sure if something violates a policy!

This week’s tasks

  • Download R and Rstudio
  • R Basics
  • Data Visualization I and II
  • Project Topic Idea Submission Due Sunday
  • Lab 1 Due Sunday

What is Political Science?

First and foremost what is political science?

  • Political science is the scientific study of political phenomena.

    • Depending on the year you are, you have probably read at the minimum one academic article, and in these pieces you probably have seen a section on the methodology.
      • Methodology is the approach used by political scientists to provide information on events with the goal to make a causal identification.
    • In this class, you will learn the various approaches political scientists use to understand politics and how we are able to make the claims we make, such as using R!

Downloading R

Why R?

  • R is a coding language language and environment built for statistical computing and graphics that includes a large variety in statistical and graphical techniques.

  • As political scientists R is an effective way to store and handle data, and a large selection of data analysis tools including graphing tools in a coherent and effective language.

  • The majority of users will use Rstudio an IDE or integrated development environment to write the code and see outputs.

    • Rstudio is a software application with a code editor, compiler, debugger, and project manager in a single interface that allows us to write, edit, compile, and debug code in a singular location.

R

  • R is freely maintained by an international team of developers and is available through The Comprehensive R Archive Network.

  • Follow the instructions to download R.

  • If you are using an older computer or iPad, go to Using Posit Cloud for R in the FAQ page.

Instructions for Downloading R

  • Go to The Comprehensive R Archive Network webpage:

  • To install R on Windows, click the “Download R for Windows” link.

  • To install R on a Mac, click the “Download R for Mac” link.

Downloading RStudio

What is Rstudio?

  • One way to picture what RStudio does is to compare it to Microsoft Word, a software application that allows us to write documents.

  • RStudio, instead of being a platform to write text, helps us write in the coding language R. Follow the instructions below to download RStudio.

    • In more complex terms Rstudio is an IDE for R

Instructions for Downloading Rstudio

  • Go to the Posit RStudio Desktop page.

  • To install for Mac:

  • Scroll to the button that says “Install R on a Mac,” and click the “Download R for Mac OS 13+” link.

    • If you’re using an older version, click the “Previous Versions” link to find a version that works with your computer.
  • To install for Windows:

    • Scroll to the button that says “Install R on Windows 10/11,” and click the link to download.

R Basics

R as a language

  • Think of R as a language it has: vocabulary, punctuation, grammar, and syntax

  • R is a language you can use to speak to your computer to tell it how to manage and visual data

R Layout

There are four primary quadrants in RStudio:

  • Source pane
  • Console pane
  • Environment pane
  • Output pane

R Layout

RStudio Layout

Working Directory

What is a working directory?

The working directory is the folder in your computer that you have set to save files to during your working session on R.

Essentially, you are telling your computer to save any new documents or updates to this specific folder, rather than maybe your downloads folder.

Step 1: Make a Folder

  • Mac

    • Open Finder and click Desktop on the left side

      • On the top of your screen got to File and click New Folder

        • Name this folder POL 051 - SU26
  • Windows

    • Open File Explorer and go to Desktop

      • Click/tap on New on the command bar, and click/tap on Folder in the drop menu.

        • Name this folder POL 051 - SU26

Step 2: Create the Working Directory.

To create a new working directory in RStudio:

  1. Use File → New Project or use the New Project button (available on the Projects toolbar in the top right corner or on the global toolbar at the top left corner).
  2. This will open the “New Project Wizard” popup.
  3. Click “New Directory”.

Step 3: Set the Working Directory.

# Set working directory (replace this with your own)

# Mac Users
setwd("/Users/yourname/Desktop/filename/filename")

# Windows Users
setwd("C:/Users/YourName/Documents/MyFolder")

# To check if the working directory is set correctly, use the following code:

# Returns the filepath of the current working directory
getwd()

Application exercise

Submit a .qmd file of the code from class today. The template can be found on Week 1 on our course website.

R Coding Basics

Writing “Text”

  • Writing text in R is called a script, a strong of letters connected by the use of ” ” or ’ ’.
"Hello World!"
[1] "Hello World!"
'Hello World!' 
[1] "Hello World!"

Writing Numbers

  • To output numbers you just type out the number. Also, note that I do not use a comma when writing out my four-digit number:
5
[1] 5
75
[1] 75
1000
[1] 1000

Basic Calculations

R at its core is a gigantic calculator, so let’s practice doing basic calculations.

# addition
10 + 2

# subtraction
10 - 2

# multipilication
10 * 2

# division
10/2

# exponent
10^2

Basic Calculations

R at its core is a gigantic calculator, so let’s practice doing basic calculations.

# addition
10 + 2
[1] 12
# subtraction
10 - 2
[1] 8
# multipilication
10 * 2
[1] 20
# division
10/2
[1] 5
# exponent
10^2
[1] 100

Comments

It’s also important to annotate your code. It will help you write notes and explain what you are doing. To annotate your code, you will use the number sign #:

# addition
10 + 2
[1] 12
# the answer is 12

Creating Objects

In R, we save our data in what we call objects! Objects store information about different types of elements. If you know any other coding languages, they typically call these variables.

  • print() is a function that ‘prints’ out an output from an object.

  • R functions are like the verbs of the R coding language, they tell your computer what action to make with sets of information.

    • A function is usually defined by a keyword and then parenthesis.
# The <- saves the caculation as math
math <- 10 + 2
#print()
print(math)
[1] 12
# The = saves the caculation as math
math = 10 + 2
# print() will print out what is saved in the object math
print(math)
[1] 12

Data Types

There are 6 types of data in R that are important to know, but the essential ones are logical, numeric, and character.

In this class we are going to focus on only three: Logical, Numeric, and Characters.

  1. Logical Also known as boolean data, logical data is shown as TRUE or FALSE values:
logical1 <- TRUE
logical2 <- FALSE

# The class() function outputs the data type of the object
class(logical1)
[1] "logical"
print(logical2)
[1] FALSE
print(class(logical2))
[1] "logical"

Data Types

  1. Numeric represents all data types that are real numbers with or with out decimal points.
height <- 5.5
acres <- 1000

class(height)
[1] "numeric"
print(acres)
[1] 1000
print(class(acres))
[1] "numeric"

Data Types

  1. Character specifies character or string values in a variable such as a singular character ‘A’ or a string of characters in ‘Apple’.
# Use '' or "" to show it's a string of characters
motorsports <- "formula1"

print(motorsports)
[1] "formula1"
print(class(motorsports))
[1] "character"

Packages

What is a Package?

  • Packages are collections of R functions, data, and code compiled in a well-defined format

  • Some packages come pre-installed in R.

  • However, the majority do not, so you need to install them first using the r function install.packages

install.packages("tidyverse") # install this package

Using a Package

  • After installing the packages we need to “attach” the package.

    • This means telling your computer that you want to use that package during this working session
  • You can do this by using the function library() and the name of the package.

library("tidyverse")