This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Binary agreement with "Comedians should be allowed to say what they want without any restrictions." | |
gen q25r7_bin = (q25r7 >=4) if !mi(q25r7) | |
* Generate party ID labels/variables | |
gen Democrat = (q6a <=3) | |
gen Republican = (q6a ==5 | q6a ==6 | q6a ==7 ) | |
tabstat q25r7_bin [aw=WEIGHT] if Democrat==1 | |
tabstat q25r7_bin [aw=WEIGHT] if Republican==1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The expand parameter controls the padding around your data on each axis. | |
# By default, ggplot2 adds approximately 5% padding on each side of your data range to ensure data points don't touch the plot boundaries. | |
# Setting expand = c(0, 0) removes this padding entirely: | |
library(patchwork) | |
data <- data.frame( | |
category = c("Category A", "Category B", "Category C"), | |
value = c(25, 40, 30) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(haven) | |
# Get data from https://www.chesdata.eu/ches-europe | |
## Look for: Special Edition Chapel Hill Expert Surveys (SPEED CHES) - 2023 SPEED CHES - Ukraine | |
uk <- read_dta("CHES_Ukraine_Feb2024.dta") | |
# Or run: | |
# uk <- read_csv("https://raw.githubusercontent.com/zilinskyjan/code-and-data/master/politics/CHES_Ukraine_Feb2024.csv") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Get data from: https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi%3A10.7910/DVN/PR4L8P | |
use "CCES22_Common_OUTPUT_vv_topost.dta", clear | |
* net install cibar, from("http://fmwww.bc.edu/RePEc/bocode/c") replace | |
* ssc install schemepack, replace | |
gen age = 2022-birthyr | |
* Keeping the main categories (99.27% of observations) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_pal <- rcartocolor::carto_pal(n = 7, name = "ag_Sunset") | |
col2 <- rcartocolor::carto_pal(n=7,name="Burg") | |
Bold <- rcartocolor::carto_pal(n=12,name="Bold") | |
Fall2 <- rcartocolor::carto_pal(n=2,name="Fall") | |
Geyser2 <- rcartocolor::carto_pal(n=2,name="Geyser") | |
library(showtext) | |
font_add_google("Outfit", "Outfit") | |
font_add_google("Cabin", "Cabin") | |
#font_add_google("Montserrat", "Montserrat") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
allHandles <- read_csv("https://raw.githubusercontent.com/USATODAY/clustering-congress-twitter/main/data/source/cong_handles_master_and_ids08082022.csv") | |
cong117 <- allHandles %>% filter(c117th==1) %>% | |
select( | |
twitter_handle = twitter_lower, | |
state, district, party, chamber, | |
Official) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(haven) | |
library(labelled) | |
library(stargazer) | |
# Download data from: https://dataverse.harvard.edu/file.xhtml?fileId=4363671&version=1.0 | |
d2 <- read_dta("Clean Data, Study 2.dta") | |
d2$college_grad <- ifelse(d2$edu >= 5,1,0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Download Nationscape data | |
* [either make a cumulative file, or just use Wave 47, June 2020] | |
* URL: https://www.voterstudygroup.org/publication/nationscape-data-set | |
gen Men = (gender==2) if !mi(gender) | |
recode age (18/29=1 "Age: 18-29 years") (30/44=2 "30-44 years") (45/64=3 "45-64 years") (65/110=4 "65+ years"), gen(age_group) | |
gen registered = (registration==1) if !mi(registration) | |
gen intendsToVote = (vote_intention==1) if !mi(vote_intention) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Get data from Roper center | |
* Downloadable from: https://ropercenter.cornell.edu/ipoll/study/31114169 | |
use "31114169.DTA" | |
* Table: | |
tab hrctrump WIN16 [aw=weight], row nof | |
* 89% of Clinton voters and 61% of third-party voters expected a Clinton victory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Question: how many 2008 Obama voters voted | |
* for a Republican congressional candidate in 2010 and then | |
* voted for Obama in '12? | |
* | |
* Asked by Dan Pfeiffer here https://twitter.com/danpfeiffer/status/1191492977429893120 | |
* Step 1: Download the 2010-2014 Cooperative Congressional Election Study Panel Survey | |
* from https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi%3A10.7910/DVN/TOE8I1 | |
use "CCES_Panel_Full3waves_VV_V4.dta", clear |
NewerOlder