This page contains code for R plots made using ggplot from the tidyverse package. The code often isn’t intended to be ideal, but to instead include more code than needed, because it’s easier to delete code than to add code. A thorough list to theme elements is available here.
You can add at the end of the code a ggsave command to save to your working directory, such as…
ggsave("plot1.svg", width = 10, height = 5)
…or you can add the directory to the command, such as…
ggsave("G:/data/plot1.svg", width = 10, height = 5)
The command getwd() will return the working directory, and the command setwd() can be used to set the working directory.
theme.z <- theme( axis.text.x.bottom = element_text(size = 15, color = "black", hjust = 0.5, vjust = 0.5, margin = margin(t = 5, r = 5, b = 5, l = 5)), axis.text.x.top = element_text(size = 15, color = "black", hjust = 0.5, vjust = 0.5, margin = margin(t = 5, r = 5, b = 5, l = 5)), axis.text.y.left = element_text(size = 15, color = "black", hjust = 0.5, vjust = 0.5, margin = margin(t = 5, r = 5, b = 5, l = 5)), axis.text.x.right = element_text(size = 15, color = "black", hjust = 0.5, vjust = 0.5, margin = margin(t = 5, r = 5, b = 5, l = 5)), axis.ticks.x = element_blank(), axis.ticks.y = element_blank(), axis.title.x = element_text(size = 15, color = "black", hjust = 0.5, vjust = 0.5, margin = margin(t = 5, r = 5, b = 5, l = 5)), axis.title.y = element_text(size = 15, color = "black", hjust = 0.5, vjust = 0.5, margin = margin(t = 5, r = 5, b = 5, l = 5)), axis.title.y.right = element_text(size = 15, color = "black", hjust = 0.5, vjust = 0.5, margin = margin(t = 5, r = 5, b = 5, l = 5), angle = 0), legend.position = "none", panel.background = element_rect(linewidth = 0.5, color = "black", linetype = "solid", fill = "gray90"), panel.border = element_rect(linewidth = 1.0, color = "black", linetype = "solid", fill = NA), panel.grid.major.x = element_blank(), panel.grid.major.y = element_blank(), panel.grid.minor.x = element_blank(), panel.grid.minor.y = element_blank(), panel.spacing.x = unit(1, "lines"), panel.spacing.y = unit(1, "lines"), plot.background = element_rect(fill = "white"), plot.caption = element_text(size = 12, color = "black", hjust = 0, vjust = 0.5, margin = margin(t = 5, r = 5, b = 5, l = 5)), plot.margin = unit(c(t = 10, r = 10, b = 10, l = 10), "pt"), plot.subtitle = element_text(size = 15, color = "black", hjust = 0.5, vjust = 0.5, margin = margin(t = 5, r = 5, b = 5, l = 5)), plot.title = element_text(size = 20, color = "black", hjust = 0.5, vjust = 0.5, margin = margin(t = 5, r = 5, b = 5, l = 5), face = "bold"), strip.background = element_rect(linewidth = 1, color = "black", linetype = "solid", fill = "black"), strip.text.x = element_text(size = 18, color = "white", hjust = 0.5, vjust = 0.5, margin = margin(t = 5, r = 5, b = 5, l = 5), face = "bold"), strip.text.y = element_text(size = 18, color = "white", hjust = 0.5, vjust = 0.5, margin = margin(t = 5, r = 5, b = 5, l = 5), face = "bold") )
This next plot is a regression-type plot in which the analysis does not assume a constant association between the predictor and the outcome net of controls. The data for this plot are loaded using a tribble command. But, as used in some plots below, data can be loaded from an external file.
library(tidyverse)
DATA <- tribble(
~X, ~PE , ~CILO, ~CIHI, ~N,
0, 32.4, 26.5, 38.3, 297,
1, 41.4, 33.0, 49.9, 103,
2, 38.6, 29.2, 48.0, 97,
3, 45.8, 37.2, 54.4, 107,
4, 44.8, 37.0, 52.6, 236,
5, 57.3, 45.0, 69.5, 144,
6, 70.6, 55.0, 86.3, 129,
7, 58.0, 49.8, 66.1, 113,
8, 56.8, 47.7, 65.8, 163,
9, 70.6, 62.0, 79.2, 102,
10, 73.9, 66.8, 81.0, 145,
11, 72.0, 58.8, 85.3, 96,
12, 74.4, 64.4, 84.5, 78,
13, 75.9, 63.1, 88.8, 32,
14, 63.2, 40.3, 86.2, 18,
15, 55.1, 16.4, 94.0, 12,
16, 77.8, 46.7, 95.0, 18)
theme.z <- theme(
axis.text.x = element_text(size = 15, color = "black", hjust = 0.5, margin = margin(t = 8, b = 8)),
axis.text.y = element_text(size = 15, color = "black", vjust = 0.5, margin = margin(r = 7, l = 7)),
axis.text.y.right = element_text(size = 15, color = "black", vjust = 0.5, margin = margin(r = 7, l = 7)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_text(size = 15, color = "black", hjust = 0.5, margin = margin(t = 8, b = 8)),
axis.title.y = element_blank(),
axis.title.y.right = element_blank(),
panel.background = element_rect(linewidth = 0.5, fill = "gray90"),
panel.border = element_rect(linewidth = 1.0, fill = NA ),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 12, hjust = 0 , margin = margin(t = 10)),
plot.margin = unit(c(t = 10, r = 10, b = 10, l = 10),"pt"),
plot.subtitle = element_text(size = 15, hjust = 0.5, margin = margin(t = 0, b = 8)),
plot.title = element_text(size = 20, hjust = 0.5, margin = margin(t = 0, b = 16), face = "bold")
)
CAPTION <- str_wrap("Data source: XXX\nError bars indicate 95% confidence intervals.\nNumbers on the inside bottom (e.g., 297) are sample sizes for that level of the predictor.", width = 95)
ggplot(data = DATA, mapping = aes(x = X, y = PE)) +
geom_rect(data = DATA, mapping = aes(xmin = -Inf, xmax = Inf, ymin = min(PE), ymax = max(PE)), fill = "lightsteelblue3", col = "black") +
geom_errorbar(mapping = aes(ymin = CILO, ymax = CIHI), width = 0, size = 0.75) +
geom_point(size = 3.5) +
geom_text(x = DATA$X, y = 5, vjust = 0, label = DATA$N, size = 5) +
scale_x_continuous(limits = c(0,16), breaks = seq(0,16,1)) +
scale_y_continuous(limits = c(0,100), breaks = seq(0,100,10), labels = seq(0,100,10), expand = c(0,0),
sec.axis = dup_axis()) +
labs(title = "Predicted outcome", x = "x variable", caption = CAPTION) +
theme.z
library(tidyverse)
DATA <- tribble(
~RESPONSE , ~PE , ~CILO , ~CIHI ,
"Cold to Whites but not Blacks" , 0.7733116, 0.7254376, 0.8211857,
"Residual colder to Whites than Blacks", 0.5888966, 0.5624021, 0.615391 ,
"Rated Whites equal to Blacks" , 0.3925516, 0.3580722, 0.427031 ,
"Did not rate Whites and/or Blacks" , 0.3239428, 0.2534674, 0.3944182,
"Residual colder to Blacks than Whites", 0.238854 , 0.2193636, 0.2583444,
"Cold to Blacks but not Whites" , 0.1205505, 0.0998559, 0.1412452)
DATA$RESPONSE <- factor(DATA$RESPONSE, levels = unique(DATA$RESPONSE))
theme.z <- theme(
axis.text.x = element_blank(),
axis.text.x.top = element_text(size = 15, color = "black", hjust = 1 , margin = margin(t = 8,b = 8)),
axis.text.y = element_text(size = 15, color = "black", hjust = 1 , margin = margin(l = 8,r = 8)),
axis.text.y.right = element_blank(),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.background = element_rect(linewidth = 0.5, color = "black", fill = "gray90", linetype = "solid"),
panel.border = element_rect(linewidth = 1.0, color = "black", fill = NA , linetype = "solid"),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
panel.spacing.x = unit(2, "lines"),
panel.spacing.y = unit(1, "lines"),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 12 , hjust = 0 , margin = margin(t = 10)),
plot.margin = unit(c(t = 10,r = 10,b = 10,l = 10),"pt"),
plot.subtitle = element_text(size = 15 , hjust = 0.5, margin = margin(b = 10)),
plot.title = element_text(size = 20 , hjust = 0.5, margin = margin(t = 0,b = 8), face = "bold")
)
CAPTION <- str_wrap("Note: Predicted probabilities, with the outcome coded 1 for\nstrongly approve and somewhat approve and 0 for\nsomewhat disapprove, strongly disapprove, don't know,\nand skipped. Controls only for participant race. Error bars are\n83.4% confidence intervals. Data source: 2017/8 waves of the\nDemocracy Fund Voter Study Group. 2021.\nViews of the Electorate Research Survey. Washington, D.C.\nhttps://www.voterstudygroup.org/.", width = 50)
ggplot(DATA, mapping = aes(x = PE, y = RESPONSE)) +
geom_rect(xmin = DATA$CILO[DATA$RESPONSE == "Rated Whites equal to Blacks"], xmax = DATA$CIHI[DATA$RESPONSE == "Rated Whites equal to Blacks"], ymin = -Inf, ymax = Inf, fill = "slategray3", color = NA) +
geom_errorbarh(mapping = aes(xmin = CILO, xmax = CIHI), height = 0) +
geom_point(color = "black", size = 3.5) +
scale_x_continuous(limits = c(0,1), breaks = seq(0,1,by = 0.2), expand = c(0,0)) +
geom_text(x = 0.975, y = DATA$RESPONSE, size = 5, hjust = 1, label = format(round(DATA$PE, 2), nsmall = 2)) +
labs(title = "Approve of anthem protests", caption = CAPTION) +
theme.z
This next plot plots data across multiple facets. The lines with “filter” are used to make sure that particular elements appear only in certain facets.
Lines in the section that start with “DATA$max” or “DATA$min” are intended to reduce the length of later lines of code.
library(tidyverse)
DATA <- tribble(
~RESPONDENTS , ~TARGET , ~PE, ~CILO, ~CIHI,
"White respondents" , "Mean ratings of Whites" , 71.03, 70.47, 71.59,
"White respondents" , "Mean ratings of Blacks" , 70.14, 69.57, 70.72,
"White respondents" , "Mean ratings of Hispanics", 70.49, 69.93, 71.04,
"White respondents" , "Mean ratings of Asians" , 70.24, 69.68, 70.8 ,
"Black respondents" , "Mean ratings of Whites" , 62.2 , 60.24, 64.17,
"Black respondents" , "Mean ratings of Blacks" , 85.36, 83.93, 86.79,
"Black respondents" , "Mean ratings of Hispanics", 71.07, 69.37, 72.78,
"Black respondents" , "Mean ratings of Asians" , 66.2 , 64.32, 68.07,
"Hispanic respondents", "Mean ratings of Whites" , 65.17, 63.46, 66.89,
"Hispanic respondents", "Mean ratings of Blacks" , 72.47, 70.95, 73.99,
"Hispanic respondents", "Mean ratings of Hispanics", 80.55, 79.04, 82.05,
"Hispanic respondents", "Mean ratings of Asians" , 72.3 , 70.77, 73.84,
"Asian respondents" , "Mean ratings of Whites" , 67.4 , 64.54, 70.27,
"Asian respondents" , "Mean ratings of Blacks" , 70.54, 68.01, 73.07,
"Asian respondents" , "Mean ratings of Hispanics", 69.68, 67.16, 72.21,
"Asian respondents" , "Mean ratings of Asians" , 80.28, 78.1 , 82.46)
DATA$RESPONDENTS <- factor(DATA$RESPONDENTS, levels = unique(DATA$RESPONDENTS))
DATA$TARGET <- factor(DATA$TARGET , levels = rev(unique(DATA$TARGET)))
DATA$max.w <- max(DATA$PE[DATA$RESPONDENTS == "White respondents"] , na.rm = TRUE)
DATA$min.w <- min(DATA$PE[DATA$RESPONDENTS == "White respondents"] , na.rm = TRUE)
DATA$max.b <- max(DATA$PE[DATA$RESPONDENTS == "Black respondents"] , na.rm = TRUE)
DATA$min.b <- min(DATA$PE[DATA$RESPONDENTS == "Black respondents"] , na.rm = TRUE)
DATA$max.h <- max(DATA$PE[DATA$RESPONDENTS == "Hispanic respondents"], na.rm = TRUE)
DATA$min.h <- min(DATA$PE[DATA$RESPONDENTS == "Hispanic respondents"], na.rm = TRUE)
DATA$max.a <- max(DATA$PE[DATA$RESPONDENTS == "Asian respondents"] , na.rm = TRUE)
DATA$min.a <- min(DATA$PE[DATA$RESPONDENTS == "Asian respondents"] , na.rm = TRUE)
CAPTION <- str_wrap("Note: Error bars are 83.4% confidence intervals. Data source: American National Election Studies. 2021. ANES 2020 Time Series Study Preliminary Release: Combined Pre-Election and Post-Election Data [dataset and documentation]. March 24, 2021 version. www.electionstudies.org.", width = 92)
theme.z <- theme(
axis.text.x = element_text(size = 15, color = "black", margin = margin(t = 8,b = 8)),
axis.text.y = element_text(size = 15, color = "black", margin = margin(l = 8,r = 8)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.background = element_rect(linewidth = 0.5, color = "black", fill = "gray90", linetype = "solid"),
panel.border = element_rect(linewidth = 1.0, color = "black", fill = NA , linetype = "solid"),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
panel.spacing.x = unit(2, "lines"),
panel.spacing.y = unit(1, "lines"),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 10, hjust = 0, margin = margin(t = 8)),
plot.margin = unit(c(0.5,0.5,0.5,0.5),"cm"),
plot.subtitle = element_text(size = 15, hjust = 0.5, margin = margin(b = 7)),
plot.title = element_text(size = 20, hjust = 0.5, face = "bold", margin = margin(t = 0,b = 12)),
strip.background = element_rect(linewidth = 1, color = "black", fill = "black"),
strip.text.x = element_text(size = 17, color = "white", face = "bold", margin = margin(t = 7.5,b = 7.5))
)
ggplot(data = DATA, mapping = aes(x = PE, y = TARGET)) +
facet_wrap(~RESPONDENTS, nrow = 2, dir = "v") +
geom_rect(data = filter(DATA, RESPONDENTS == "White respondents") ,
mapping = aes(xmin = min.w, xmax = max.w, ymin = -Inf, ymax = Inf), fill = "lightsteelblue3", color = "black", inherit.aes = FALSE) +
geom_rect(data = filter(DATA, RESPONDENTS == "Black respondents") ,
mapping = aes(xmin = min.b, xmax = max.b, ymin = -Inf, ymax = Inf), fill = "lightsteelblue3", color = "black", inherit.aes = FALSE) +
geom_rect(data = filter(DATA, RESPONDENTS == "Hispanic respondents"),
mapping = aes(xmin = min.h, xmax = max.h, ymin = -Inf, ymax = Inf), fill = "lightsteelblue3", color = "black", inherit.aes = FALSE) +
geom_rect(data = filter(DATA, RESPONDENTS == "Asian respondents") ,
mapping = aes(xmin = min.a, xmax = max.a, ymin = -Inf, ymax = Inf), fill = "lightsteelblue3", color = "black", inherit.aes = FALSE) +
geom_point(size = 3.5) +
geom_errorbarh(mapping = aes(xmin = CILO, xmax = CIHI), height = 0, size = 0.75) +
scale_x_continuous(breaks = seq(0,100,25), limits = c(0,100), labels = scales::number_format(accuracy = 1)) +
labs(title = "How racial groups rate each other", caption = CAPTION) +
theme.z
library(tidyverse)
DATA <- tribble(
~GROUP ,~PE,~CILO83,~CIHI83,~CILO95,~CIHI95,
"Racial resentment of 0 on 0-to-12 index (N = 66)" ,-0.2922794,-0.448513,-0.1360458,-0.515034,-0.0695248,
"Racial resentment of 0 or 1 on a 0-to-12 index (N = 107)" ,-0.2216749,-0.3462494,-0.0971004,-0.3987587,-0.0445911,
"Racial resentment of less than 6 on a 0-to-12 index (N = 298)" ,-0.243315,-0.3211188,-0.1655112,-0.3535838,-0.1330462,
"At least 1 negative stereotype of Whites compared to Blacks (N = 165)",-0.1875,-0.2945985,-0.0804015,-0.3394902,-0.0355098,
"At least 2 negative stereotypes of Whites compared to Blacks (N = 87)",-0.3123679,-0.4537431,-0.1709926,-0.5135549,-0.1111809,
"Three negative stereotypes of Whites compared to Blacks (N = 43)" ,-0.3549784,-0.552015,-0.1579417,-0.6371384,-0.0728183,
"Rated Whites < 50 on 0-to-100 thermo but Blacks 50 or above (N = 39)" ,-0.4603175,-0.6502958,-0.2703391,-0.732731,-0.1879039,
"Rated Whites lower than Blacks on 0-to-100 thermo (N = 205)" ,-0.2152381,-0.3090966,-0.1213796,-0.3483605,-0.0821157)
DATA$GROUP <- factor(DATA$GROUP, levels = DATA$GROUP)
theme.z <- theme(
plot.background = element_rect(fill = "white"),
strip.background = element_rect(linewidth = 1, color = "black", fill = "black"),
strip.text.x = element_text(color = "white", face = "bold", size = 15, margin = margin(t = 7.5, b = 7.5)),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
panel.background = element_rect(fill = "gray90", color = "black", linewidth = 0.5, linetype = "solid"),
panel.border = element_rect(fill = NA, color = "black", linetype = "solid", linewidth = 1.0),
panel.spacing.x = unit(1, "lines"),
panel.spacing.y = unit(1, "lines"),
axis.title.y = element_blank(),
axis.title.x = element_text(size = 12, color = "black"),
axis.ticks.y = element_blank(),
axis.ticks.x = element_blank(),
axis.text.x = element_text(size = 12, color = "black", vjust = -1),
axis.text.y = element_text(size = 12, color = "black", margin = margin(r = 10)),
plot.margin = unit(c(0.5,0.5,0.5,0.5),"cm"),
plot.title = element_text(face = "bold", margin = margin(t = 0, b = 13), size = 15, hjust = 0.5),
plot.subtitle = element_text(hjust = 0.5, size = 12),
plot.caption = element_text(hjust = 0, size = 9)
)
CAPTION <- str_wrap("Thick error bars are 83.4% confidence intervals. Thin error bars are 95% confidence\nintervals. Estimates are from unweighted analyses, indicating percentage point\ndifferences in rating the Black target guilty relative to the White target. Total\nN is 649 Whites with responses for the 'guilty' item. Data source: Rice et al. 2021", width = 80)
ggplot(DATA, mapping = aes(100*PE, GROUP)) +
geom_rect(mapping = aes(xmin = 0, xmax = Inf, ymin = -Inf, ymax = Inf), linewidth = 1, color = "black", fill = "slategray3") +
geom_errorbarh(mapping = aes(xmin = 100*CILO95, xmax = 100*CIHI95), height = 0, size = 0.5, color = "gray60") +
geom_errorbarh(mapping = aes(xmin = 100*CILO83, xmax = 100*CIHI83), height = 0, size = 1.5) +
geom_point(shape = 21, color = "black", fill = "slategray3", size = 4, stroke = 2) +
scale_x_continuous(name = "", breaks = seq(-80,20,20), limits = c(-80,20), labels = scales::number_format(accuracy = 1)) +
geom_text(mapping = aes(x = 20, label = scales::percent(PE, accuracy = 1L)), position = position_dodge(width = 0.7), hjust = 1, size = 4.5) +
labs(title = "Pro-Black Mock Juror Bias, among Whites", caption = CAPTION) +
theme.z
library(tidyverse)
DATA <- tribble(
~GROUP , ~RESPONSE , ~PE , ~CILO , ~CIHI ,
"Population A", "Response 1", 0.2487805, 0.2316981, 0.2666853,
"Population A", "Response 2", 0.3466610, 0.3276461, 0.3661784,
"Population B", "Response 1", 0.3337802, 0.3079924, 0.3606019,
"Population B", "Response 2", 0.3705482, 0.3441236, 0.3977713,
"Population C", "Response 1", 0.1463591, 0.1274313, 0.1675585,
"Population C", "Response 2", 0.3190987, 0.2921480, 0.3473157,
"Population D", "Response 1", 0.2456283, 0.2256315, 0.2667868,
"Population D", "Response 2", 0.3202551, 0.2983380, 0.3429953,
"Population E", "Response 1", 0.1215903, 0.0810799, 0.1784114,
"Population E", "Response 2", 0.3515452, 0.2775312, 0.4334554,
"Population F", "Response 1", 0.3167555, 0.2472624, 0.3955174,
"Population F", "Response 2", 0.2819693, 0.2294461, 0.341192,
"Population G", "Response 1", 0.2613607, 0.2113523, 0.3184242,
"Population G", "Response 2", 0.4241733, 0.3645215, 0.4861194)
DATA$RESPONSE <- factor(DATA$RESPONSE, levels = rev(unique(DATA$RESPONSE)))
DATA$GROUP <- factor(DATA$GROUP , levels = rev(unique(DATA$GROUP)))
STR <- str_wrap("Note about the plot. Data source: American National Election Studies. 2022. ANES 2022 Pilot Study [dataset and documentation]. December 14, 2022 version. www.electionstudies.org.", width = 75)
theme.z <- theme(
axis.text.x = element_text(color = "black", size = 15, margin = margin(t = 5)),
axis.text.y = element_text(color = "black", size = 15, margin = margin(r = 5)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
legend.background = element_rect(fill = "gray90"),
legend.box.background = element_rect(color = "black", linewidth = 1.5),
legend.key = element_rect(fill = "gray90"),
legend.justification = c("right", "top"),
legend.margin = margin(15,15,15,15),
legend.position = c(0.95,0.9),
legend.spacing.x = unit(10, "pt"),
legend.spacing.y = unit(10, "pt"),
legend.text = element_text(size = 15, margin = margin(t = 0)),
legend.title = element_text(size = 15, face = "bold"),
panel.background = element_rect(fill = "gray90"),
panel.border = element_rect(fill = NA, color = "black", linetype = "solid", linewidth = 1.0),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.caption = element_text(size = 11, hjust = 0, margin = margin(15,0,0,0)),
plot.subtitle = element_text(hjust = 0.5),
plot.margin = unit(c(t = 15,r = 25,b = 15,l = 15),"pt"),
plot.title = element_text(face = "bold", margin = margin(t = 0, b = 6), size = 20, hjust = 0.5)
)
ggplot(DATA, mapping = aes(color = RESPONSE, x = 100*PE, y = GROUP)) +
geom_errorbarh(mapping = aes(xmin = 0, xmax = 100), height = 0, size = 10, color = "gray80", alpha = 0.5) +
geom_errorbarh(mapping = aes(xmin = 100*(CILO), xmax = 100*(CIHI)), height = 0, size = 10, color = "steelblue", alpha = 0.5) +
geom_point(size = 3, shape = 19) +
scale_color_manual(values = c("Response 2" = "black","Response 1" = "white")) +
scale_x_continuous(limits = c(0,100), breaks = seq(0,100,by = 10), expand = c(0,0)) +
labs(title = "Title for the plot", caption = STR) +
theme.z
This first plot is a column plot from a draft figure from Zigerell 2022 “Introducing Political Science Students to Data Visualization Strategies” in the Journal of Political Science Education.
library(tidyverse)
DATA <- tribble(
~PID , ~PE , ~CILO , ~CIHI ,
"Strong\nDemocrat" , 0.4445886, 0.4089648, 0.4802125,
"Not strong\nDemocrat" , 0.2726622, 0.2290617, 0.3162628,
"Independent\nDemocrat" , 0.2509012, 0.218784 , 0.2830185,
"Independent" , 0.2135729, 0.1755062, 0.2516396,
"Independent\nRepublican", 0.2633814, 0.218896 , 0.3078668,
"Not strong\nRepublican" , 0.2074255, 0.1671848, 0.2476663,
"Strong\nRepublican" , 0.3374613, 0.308117 , 0.3668057)
DATA$PID <- factor(DATA$PID, levels = DATA$PID)
CAPTION <- str_wrap("Note: Error bars are 83.4% confidence intervals. Estimates are from a logit regression, with weights applied and with categorical controls for gender, race, age group, education, marital status, household income, and gun ownership set at their means. Data source: American National Election Studies 2020 Time Series Study (2021).", width = 125)
TITLE <- c("Predicted probability of responding\n\"extremely important\" about how important\nthe respondent considers the issue of the federal gun laws")
theme.z <- theme(
axis.text.x = element_text(size = 15, color = "black", hjust = 0.5, margin = margin(t = 8,b = 8)),
axis.text.y = element_blank(),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.background = element_rect(linewidth = 0.5, color = "black", fill = "gray90", linetype = "solid"),
panel.border = element_rect(linewidth = 1.0, color = "black", fill = NA , linetype = "solid"),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 12 , hjust = 0 , margin = margin(t = 10)),
plot.margin = unit(c(t = 10,r = 10,b = 10,l = 10),"pt"),
plot.subtitle = element_text(size = 15 , hjust = 0.5, margin = margin(b = 10)),
plot.title = element_text(size = 20 , hjust = 0.5, margin = margin(t = 0,b = 15), face = "bold")
)
ggplot(data = DATA, mapping = aes(x = PID, y = PE)) +
geom_col(color = "black", fill = c(rep_len("blue3",2), rep_len("gray50",3), rep_len("red3",2)),
linewidth = 1.1, width = 0.8) +
geom_text(mapping = aes(y = CIHI, label = scales::percent(PE, accuracy = 1L)), size = 5, hjust = 0.5, vjust = -1) +
geom_errorbar(mapping = aes(ymin = CILO, ymax = CIHI), size = 0.75, width = 0.25) +
scale_x_discrete() +
scale_y_continuous(expand = c(0,0), limits = c(0,1), sec.axis = (dup_axis())) +
labs(title = TITLE, y = "Probability", caption = CAPTION) +
theme.z
library(tidyverse)
DATA <- tribble(
~RESPONSE, ~GROUP,~PE,~CILO,~CIHI,~CILO.STACK,~CIHI.STACK,
"Rated only men cold","Strong feminist",0.2244495,0.1734468,0.2852736,0.1734468,0.2852736,
"Rated only men cold","Feminist",0.1369234,0.1121956,0.1660818,0.1121956,0.1660818,
"Rated only men cold","Not a feminist",0.0818824,0.0684379,0.0976912,0.0684379,0.0976912,
"Rated only men cold","Anti-feminist",0.1230189,0.0776477,0.189456,0.0776477,0.189456,
"Residual colder to men","Strong feminist",0.4957903,0.4315959,0.5601238,0.6560454,0.7845733,
"Residual colder to men","Feminist",0.548797,0.5072817,0.5896439,0.6442051,0.7265673,
"Residual colder to men","Not a feminist",0.4317206,0.4061719,0.4576378,0.4880543,0.5395202,
"Residual colder to men","Anti-feminist",0.2593538,0.1988233,0.3307057,0.3218422,0.4537246,
"Rated men equal to women","Strong feminist",0.1141982,0.0770669,0.1660018,0.7973067,0.8862416,
"Rated men equal to women","Feminist",0.1583753,0.1292627,0.1925943,0.8149831,0.8783147,
"Rated men equal to women","Not a feminist",0.2650397,0.2426491,0.2887089,0.7562521,0.8023119,
"Rated men equal to women","Anti-feminist",0.2801124,0.2121814,0.3598575,0.5945541,0.7422302,
"Residual colder to women","Strong feminist",0.1357016,0.0968408,0.186929,0.9312788,1.021367,
"Residual colder to women","Feminist",0.1267096,0.099491,0.1600512,0.9435867,1.0041469,
"Residual colder to women","Not a feminist",0.1944195,0.1744745,0.2160478,0.9531172,0.9946905,
"Residual colder to women","Anti-feminist",0.2635357,0.200313,0.338272,0.8627981,1.0007571,
"Rated only women cold","Strong feminist",0.0247997,0.0091943,0.0651505,0.9793339,1.0352901,
"Rated only women cold","Feminist",0.0291947,0.0176643,0.0478848,0.9884696,1.0186901,
"Rated only women cold","Not a feminist",0.0269377,0.0196127,0.0368957,0.9926749,1.0099579,
"Rated only women cold","Anti-feminist",0.0739792,0.0371087,0.142078,0.9631295,1.0680988)
DATA$RESPONSE <- factor(DATA$RESPONSE, levels = rev(unique(DATA$RESPONSE)))
DATA$GROUP <- factor(DATA$GROUP , levels = unique(DATA$GROUP[1:5]))
theme.z <- theme(
axis.text.x = element_text(color = "black", size = 15, margin = margin(t = 0)),
axis.text.y = element_text(color = "black", size = 15, margin = margin(r = 0)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
legend.position = "none",
legend.spacing.x = unit(10, "pt"),
legend.spacing.y = unit(10, "pt"),
legend.text = element_text(size = 15, margin = margin(t = 5)),
legend.title = element_text(size = 15, face = "bold"),
panel.background = element_rect(fill = "white"),
panel.border = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.caption = element_text(size = 11, hjust = 0, margin = margin(15,0,0,0)),
plot.subtitle = element_text(hjust = 0.5),
plot.margin = unit(c(t = 15,r = 210,b = 15,l = 15),"pt"),
plot.title = element_text(face = "bold", margin = margin(t = 0, b = 6), size = 20, hjust = 0.5)
)
CAPTION <- str_wrap("Note: Cold refers to a rating under 50. Colder refers to a lower rating. Estimates are weighted. Sample size 1,498 U.S. adults, 147 strong feminists, 366 feminists,\n889 non-feminists, and 96 anti-feminists, with 2 non-responses for the feminist item and 1 non-response for the feeling thermometer items.\n83.4% confidence intervals are for the uncertainty about the indicated category (e.g., Rated men equal to women, among non-feminists).\nData source: American National Election Studies. 2022. ANES 2022 Pilot Study [dataset and documentation]. December 14, 2022 version. www.electionstudies.org.", width = 100)
ggplot(DATA, mapping = aes(fill = RESPONSE, y = 100*PE, x = GROUP)) +
geom_col(color = "black", linewidth = 1.1, width = 0.85) +
scale_fill_manual(values = rev(c("Rated only men cold" = "steelblue1","Residual colder to men" = "powderblue","Rated men equal to women" = "white","Residual colder to women" = "lightpink1","Rated only women cold" = "deeppink1")), name = "Category") +
scale_y_continuous(limits = c(0,107), breaks = seq(0,100,by = 10)) +
scale_x_discrete(limits = c("Strong feminist","Feminist","Not a feminist","Anti-feminist")) +
labs(title = "Ratings about men and about women\non 0-to-100 feeling thermometers", caption = CAPTION) +
coord_cartesian(clip = "off") +
geom_errorbar(mapping = aes(ymin = 100*(CILO.STACK), ymax = 100*(CIHI.STACK)), width = 0.5, size = 0.75, position = position_dodge(c(0.75))) +
annotate("text",x = 4.65,y = 96,size = 5.5,hjust = 0,label = "Rated only women cold") +
annotate("text",x = 4.65,y = 79,size = 5.5,hjust = 0,label = "Residual colder to women") +
annotate("text",x = 4.65,y = 52,size = 5.5,hjust = 0,label = "Rated men equal to women") +
annotate("text",x = 4.65,y = 25,size = 5.5,hjust = 0,label = "Residual colder to men") +
annotate("text",x = 4.65,y = 6,size = 5.5,hjust = 0,label = "Rated only men cold") +
theme.z
This next plot illustrates why it’s not ideal for an analysis to assume a constant association between the predictor and the outcome net of controls. The plot also includes arrows to emphasize a point of the plot. This plot appeared in Zigerell 2022 “Introducing Political Science Students to Data Visualization Strategies” in the Journal of Political Science Education.
library(tidyverse)
DATA <- read_csv("Figure 9.csv")
print(DATA, n = Inf)
## # A tibble: 36 × 5
## FACET LEVEL PE CILO CIHI
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 Con Uniform 0 -0.172 -0.236 -0.107
## 2 Con Uniform 1 -0.137 -0.191 -0.0844
## 3 Con Uniform 2 -0.103 -0.146 -0.0605
## 4 Con Uniform 3 -0.0690 -0.103 -0.0352
## 5 Con Uniform 4 -0.0348 -0.0627 -0.00690
## 6 Con Uniform 5 -0.000583 -0.0275 0.0263
## 7 Con Uniform 6 0.0336 0.00237 0.0649
## 8 Con Uniform 7 0.0679 0.0285 0.107
## 9 Con Uniform 8 0.102 0.0528 0.151
## 10 Con Relaxed 0 -0.0414 -0.195 0.112
## 11 Con Relaxed 1 -0.0477 -0.156 0.0607
## 12 Con Relaxed 2 -0.175 -0.259 -0.0918
## 13 Con Relaxed 3 -0.112 -0.198 -0.0252
## 14 Con Relaxed 4 0.0803 0.0117 0.149
## 15 Con Relaxed 5 -0.104 -0.166 -0.0416
## 16 Con Relaxed 6 -0.130 -0.194 -0.0666
## 17 Con Relaxed 7 0.196 0.123 0.269
## 18 Con Relaxed 8 0.220 0.133 0.308
## 19 Lib Uniform 0 0.101 0.0395 0.162
## 20 Lib Uniform 1 0.0899 0.0394 0.140
## 21 Lib Uniform 2 0.0793 0.0385 0.120
## 22 Lib Uniform 3 0.0687 0.0362 0.101
## 23 Lib Uniform 4 0.0581 0.0311 0.0852
## 24 Lib Uniform 5 0.0476 0.0212 0.0739
## 25 Lib Uniform 6 0.0370 0.00641 0.0675
## 26 Lib Uniform 7 0.0264 -0.0118 0.0645
## 27 Lib Uniform 8 0.0158 -0.0318 0.0633
## 28 Lib Relaxed 0 0.0426 -0.0992 0.184
## 29 Lib Relaxed 1 0.218 0.112 0.324
## 30 Lib Relaxed 2 0.0411 -0.0413 0.124
## 31 Lib Relaxed 3 -0.0297 -0.104 0.0447
## 32 Lib Relaxed 4 0.0901 0.0238 0.156
## 33 Lib Relaxed 5 -0.00485 -0.0732 0.0635
## 34 Lib Relaxed 6 0.0708 0.00751 0.134
## 35 Lib Relaxed 7 0.0869 0.0144 0.159
## 36 Lib Relaxed 8 -0.0302 -0.109 0.0491
DATA$FACET <- factor(DATA$FACET, levels = unique(DATA$FACET))
DATA$LEVEL <- factor(DATA$LEVEL, levels = 0:8)
ANNOTATE <- data.frame(FACET = c("Con Uniform","Con Relaxed","Lib Uniform","Lib Relaxed"),
label = c("p<0.05\nevidence\nof an effect","No p<0.05\nevidence\nof an effect",NA,NA))
ANNOTATE$FACET <- factor(ANNOTATE$FACET, levels = c("Con Uniform","Con Relaxed","Lib Uniform","Lib Relaxed"))
LABELS <- c("Con Uniform" = "Conservative Trump treatment\n\u2013 Uniform model \u2013", "Con Relaxed" = "Conservative Trump treatment\n\u2013 Non-uniform model \u2013", "Lib Uniform" = "Liberal Trump treatment\n\u2013 Uniform model \u2013", "Lib Relaxed" = "Liberal Trump treatment\n\u2013 Non-uniform model \u2013")
CAPTION <- str_wrap("Note: The figure reports point estimates and 95% confidence intervals from a linear regression predicting the estimated effect of a \"conservative Trump\" treatment (top panels) and a \"liberal Trump\" treatment (bottom panels) on participant responses about a policy (with a liberal response coded higher), at levels of political knowledge. Left panels depict results reported in Figure 2 of Barber and Pope (2019), which did not permit a non-uniform association. Right panels depict results that permitted a non-uniform association. Data source: Barber (2019). See Figure A14 of Barber and Pope (2019) for a plot of a different way to permit the treatment effect estimate to not be uniform.", width = 110)
theme.z <- theme(
axis.text.x = element_text(size = 15, color = "black", hjust = c(0,1), margin = margin(t = 7,r = 0,b = 5,l = 0)),
axis.text.x.top = element_blank(),
axis.text.y = element_text(size = 15, color = "black", margin = margin(r = 7, l = 7)),
axis.text.y.right = element_text(size = 15, color = "black", margin = margin(r = 7, l = 7)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
legend.position = "none",
panel.background = element_rect(linewidth = 1.0, color = "black", fill = "gray95", linetype = "solid"),
panel.border = element_rect(linewidth = 1.0, color = "black", fill = NA , linetype = "solid"),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
panel.spacing.x = unit(1, "lines"),
panel.spacing.y = unit(1, "lines"),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 12, hjust = 0 , margin = margin(t = 10)),
plot.margin = unit(c(t = 5,r = 5,b = 5,l = 5),"pt"),
plot.subtitle = element_text(size = 15, hjust = 0.5, margin = margin(b = 7)),
plot.title = element_text(size = 20, hjust = 0.5, face = "bold", margin = margin(t = 0,b = 12)),
strip.background = element_rect(linewidth = 1.0, color = "black", fill = "black"),
strip.text.x = element_text(size = 18, color = "white", face = "bold", margin = margin(t = 10,r = 10,b = 10,l = 10))
)
ggplot(data = DATA, mapping = aes(x = LEVEL, y = PE)) +
facet_wrap(vars(FACET), ncol = 2, dir = "h", labeller = as_labeller(LABELS)) +
geom_segment(x = -Inf, y = 0, xend = Inf, yend = 0, color = "gray80") +
geom_rect(xmin = -Inf, xmax = Inf, ymin = 0, ymax = Inf, fill = "gray80") +
geom_errorbar(mapping = aes(ymin = CILO, ymax = CIHI), size = 1.25, width = 0) +
geom_point(data = filter(DATA, FACET == "Con Uniform" | FACET == "Con Relaxed"),
size = 4, shape = 21, stroke = 1.5, color = "black", fill = "red3") +
geom_point(data = filter(DATA, FACET == "Lib Uniform" | FACET == "Lib Relaxed"),
size = 4, shape = 21, stroke = 1.5, color = "black", fill = "blue3") +
geom_text(data = ANNOTATE, mapping = aes(x = 2.25, y = 0.3, label = label), size = 5, hjust = 0, lineheight = 0.9) +
geom_curve(data = filter(DATA, FACET == "Con Uniform"), mapping = aes(x = 2, y = 0.35, xend = 0.9, yend = -0.08),
arrow = arrow(length = unit(0.25, "cm")), size = 0.05, curvature = 0.45) +
geom_curve(data = filter(DATA, FACET == "Con Uniform"), mapping = aes(x = 2, y = 0.30, xend = 1.8, yend = -0.08),
arrow = arrow(length = unit(0.25, "cm")), size = 0.05, curvature = 0.50) +
geom_curve(data = filter(DATA, FACET == "Con Relaxed"), mapping = aes(x = 2, y = 0.35, xend = 1 , yend = 0.18),
arrow = arrow(length = unit(0.25, "cm")), size = 0.05, curvature = 0.40) +
geom_curve(data = filter(DATA, FACET == "Con Relaxed"), mapping = aes(x = 2, y = 0.30, xend = 1.8, yend = 0.10),
arrow = arrow(length = unit(0.25, "cm")), size = 0.05, curvature = 0.50) +
scale_x_discrete(breaks = c(0,8), labels = c("Lowest\nPolitical\nKnowledge", "Highest\nPolitical\nKnowledge")) +
scale_y_continuous(limits = c(-0.5,0.5), breaks = seq(-0.4,0.4,0.2), labels = seq(-0.4,0.4,0.2),
sec.axis = dup_axis()) +
labs(title = "Estimated effect of the...", caption = CAPTION) +
theme.z
Below is a regression plot in which the analysis did assume a constant association between the predictor and the outcome net of controls. For an analysis that has that assumption, it does not make much sense to plot individual point predictions, because these points would not be independent predictions. This is a draft of a figure from Zigerell 2022 “Introducing Political Science Students to Data Visualization Strategies” in the Journal of Political Science Education.
library(tidyverse)
DATA <- read_csv("Figure 4.CSV")
print(DATA, n = Inf)
## # A tibble: 40 × 5
## FACET LEVEL PE CILO CIHI
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 Republicans 1 0.367 0.342 0.393
## 2 Republicans 2 0.371 0.350 0.393
## 3 Republicans 3 0.376 0.358 0.393
## 4 Republicans 4 0.380 0.365 0.395
## 5 Republicans 5 0.384 0.370 0.397
## 6 Republicans 6 0.388 0.375 0.402
## 7 Republicans 7 0.392 0.377 0.408
## 8 Republicans 8 0.397 0.378 0.415
## 9 Republicans 9 0.401 0.379 0.423
## 10 Republicans 10 0.405 0.379 0.432
## 11 McConnell 1 0.130 0.115 0.144
## 12 McConnell 2 0.129 0.116 0.141
## 13 McConnell 3 0.128 0.118 0.138
## 14 McConnell 4 0.127 0.118 0.136
## 15 McConnell 5 0.127 0.118 0.135
## 16 McConnell 6 0.126 0.117 0.134
## 17 McConnell 7 0.125 0.116 0.134
## 18 McConnell 8 0.124 0.114 0.135
## 19 McConnell 9 0.124 0.111 0.136
## 20 McConnell 10 0.123 0.109 0.137
## 21 Ryan 1 0.239 0.219 0.258
## 22 Ryan 2 0.242 0.226 0.259
## 23 Ryan 3 0.246 0.232 0.260
## 24 Ryan 4 0.250 0.238 0.261
## 25 Ryan 5 0.253 0.242 0.264
## 26 Ryan 6 0.257 0.246 0.268
## 27 Ryan 7 0.261 0.248 0.273
## 28 Ryan 8 0.265 0.250 0.280
## 29 Ryan 9 0.269 0.250 0.287
## 30 Ryan 10 0.272 0.251 0.294
## 31 Trump 1 0.271 0.246 0.295
## 32 Trump 2 0.296 0.274 0.318
## 33 Trump 3 0.323 0.304 0.342
## 34 Trump 4 0.351 0.334 0.368
## 35 Trump 5 0.380 0.365 0.396
## 36 Trump 6 0.410 0.395 0.426
## 37 Trump 7 0.441 0.424 0.459
## 38 Trump 8 0.472 0.451 0.493
## 39 Trump 9 0.504 0.479 0.529
## 40 Trump 10 0.535 0.505 0.565
DATA$FACET <- factor(DATA$FACET, levels = c("Trump", "McConnell", "Ryan", "Republicans"))
LABELS <- c("Republicans" = "Republicans\nin 2017", "McConnell" = "Mitch McConnell\nin 2018", "Ryan" = "Paul Ryan\nin 2018", "Trump" = "Donald Trump\nin 2018")
CAPTION <- str_wrap("Note: The figure reports results from an unweighted logit regression. Each outcome is a favorable rating, about Republicans (above 50 on a 0-to-100 feeling thermometer, with the residual category containing respondents who reported a rating 50 or lower or did not provide a rating) or the indicated Republican (very favorable or somewhat favorable, with the residual category containing respondents who selected very unfavorable or somewhat unfavorable or did not select a response). The main predictor is a measure of animus against Democratic groups, measured as the mean 0-to-100 feeling thermometer rating about Blacks, Latinos, Muslims, and gay and lesbian people. The measure of animus was coded to have ten levels with about an equal number at each level, with sample sizes between 411 and 429 for each of the ten levels. Regressions controlled for gender, race, age, education, family income, partisanship, ideology, religious attendance, and political interest. Estimates were calculated with controls at their means. Sample limited to respondents with substantive responses to all predictors and all four outcomes. Data source: VOTER study (Democracy Fund Voter Study Group 2018). Based on code from Mason et al. (2021b) and an analysis in Mason et al. (2021a), with modifications.", width = 120)
theme.z <- theme(
axis.text.x = element_text(size = 15, color = "black", hjust = c(0,1), margin = margin(t = 7,b = 7)),
axis.text.x.top = element_blank(),
axis.text.y = element_text(size = 15, color = "black", margin = margin(l = 7,r = 7)),
axis.text.y.right = element_text(size = 15, color = "black", margin = margin(l = 7,r = 7)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_text(size = 15, color = "black", margin = margin(t = 7,r = 7,b = 7,l = 7)),
axis.title.y = element_blank(),
legend.position = "none",
panel.background = element_rect(linewidth = 1.0, color = "black", fill = "gray90", linetype = "solid"),
panel.border = element_rect(linewidth = 1.0, color = "black", fill = NA, linetype = "solid"),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
panel.spacing.x = unit(1, "lines"),
panel.spacing.y = unit(1, "lines"),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 12, hjust = 0 , margin = margin(t = 10)),
plot.margin = unit(c(t = 5,r = 5,b = 5,l = 5),"pt"),
plot.subtitle = element_text(size = 15, hjust = 0.5, margin = margin(b = 7)),
plot.title = element_text(size = 20, hjust = 0.5, face = "bold", margin = margin(t = 0,b = 12)),
strip.background = element_rect(linewidth = 1.0, color = "black", fill = "black"),
strip.text.x = element_text(size = 18, color = "white", face = "bold", margin = margin(t = 10,r = 10,b = 10,l = 10))
)
ggplot(data = DATA, mapping = aes(x = LEVEL, y = PE, group = 1)) +
facet_wrap(vars(FACET), ncol = 4, dir = "v", labeller = as_labeller(LABELS)) +
geom_rect(data = filter(DATA, FACET == "Ryan"), mapping = aes(xmin = -Inf, xmax = Inf,
ymin = min(DATA$PE[DATA$FACET == "Ryan"]), ymax = max(DATA$PE[DATA$FACET == "Ryan"])), fill = "lightsteelblue3", inherit.aes = FALSE) +
geom_rect(data = filter(DATA, FACET == "McConnell"), mapping = aes(xmin = -Inf, xmax = Inf,
ymin = min(DATA$PE[DATA$FACET == "McConnell"]), ymax = max(DATA$PE[DATA$FACET == "McConnell"])), fill = "lightsteelblue3", inherit.aes = FALSE) +
geom_rect(data = filter(DATA, FACET == "Republicans"), mapping = aes(xmin = -Inf, xmax = Inf, ymin = min(DATA$PE[DATA$FACET == "Republicans"]), ymax = max(DATA$PE[DATA$FACET == "Republicans"])), fill = "lightsteelblue3", inherit.aes = FALSE) +
geom_rect(data = filter(DATA, FACET == "Trump"), mapping = aes(xmin = -Inf, xmax = Inf,
ymin = min(DATA$PE[DATA$FACET == "Trump"]), ymax = max(DATA$PE[DATA$FACET == "Trump"])), fill = "lightsteelblue3", inherit.aes = FALSE) +
geom_line(linewidth = 1.25, color = "red3") +
scale_x_continuous(name = "Animus toward Democratic groups in 2011", expand = c(0,0), breaks = c(1,10),
labels = c("Low\nanimus","High\nanimus")) +
scale_y_continuous(expand = c(0,0), limits = c(0,1), breaks = seq(0,1),
labels = scales::number_format(accuracy = 1), sec.axis = dup_axis()) +
labs(title = "Predicted probability of a favorable rating about...", caption = CAPTION) +
theme.z
library(patchwork)
library(tidyverse)
DATA <- read_csv("Rights of Man Means.csv")
print(DATA, n = Inf)
## # A tibble: 63 × 9
## LIBERT STUDY GENDER ITEM ORIGINAL PE SE CILO CIHI
## <dbl> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 6 Study 1 Women's reproductive … Low … ABscale… 0.521 0.107 0.365 0.677
## 2 6 Study 1 Women's reproductive … Sing… ABscale… 0.546 0.099 0.403 0.69
## 3 6 Study 1 Women's reproductive … Marr… ABscale… 0.521 0.105 0.369 0.673
## 4 6 Study 1 Men's reproductive au… Fair… FinAb_2x 0.624 0.084 0.502 0.745
## 5 6 Study 1 Men's reproductive au… Men … FinAb_4x 0.624 0.089 0.494 0.753
## 6 6 Study 1 Men's reproductive au… Man … FinAb_3x 0.588 0.079 0.473 0.704
## 7 6 Study 1 Men's reproductive au… Fath… FinAb_1x 0.471 0.094 0.334 0.607
## 8 6 Study 2 Women's reproductive … Low … ABscale… 0.508 0.108 0.351 0.665
## 9 6 Study 2 Women's reproductive … Sing… ABscale… 0.452 0.11 0.294 0.611
## 10 6 Study 2 Women's reproductive … Marr… ABscale… 0.468 0.112 0.305 0.631
## 11 6 Study 2 Men's reproductive au… Fair… FinAb_2x 0.611 0.078 0.498 0.724
## 12 6 Study 2 Men's reproductive au… Men … FinAb_4x 0.467 0.078 0.354 0.579
## 13 6 Study 2 Men's reproductive au… Man … FinAb_3x 0.489 0.093 0.354 0.624
## 14 6 Study 2 Men's reproductive au… Fath… FinAb_1x 0.544 0.085 0.421 0.668
## 15 6 Pooled Women's reproductive … Low … ABscale… 0.514 0.075 0.408 0.621
## 16 6 Pooled Women's reproductive … Sing… ABscale… 0.498 0.073 0.394 0.602
## 17 6 Pooled Women's reproductive … Marr… ABscale… 0.494 0.076 0.386 0.601
## 18 6 Pooled Men's reproductive au… Fair… FinAb_2x 0.617 0.056 0.537 0.697
## 19 6 Pooled Men's reproductive au… Men … FinAb_4x 0.543 0.059 0.459 0.627
## 20 6 Pooled Men's reproductive au… Man … FinAb_3x 0.537 0.061 0.45 0.624
## 21 6 Pooled Men's reproductive au… Fath… FinAb_1x 0.509 0.063 0.42 0.597
## 22 56 Study 1 Women's reproductive … Low … ABscale… 0.602 0.0567 0.523 0.682
## 23 56 Study 1 Women's reproductive … Sing… ABscale… 0.627 0.0576 0.546 0.708
## 24 56 Study 1 Women's reproductive … Marr… ABscale… 0.615 0.0544 0.538 0.691
## 25 56 Study 1 Men's reproductive au… Fair… FinAb_2x 0.609 0.0452 0.545 0.672
## 26 56 Study 1 Men's reproductive au… Men … FinAb_4x 0.7 0.0468 0.634 0.766
## 27 56 Study 1 Men's reproductive au… Man … FinAb_3x 0.657 0.0447 0.594 0.719
## 28 56 Study 1 Men's reproductive au… Fath… FinAb_1x 0.513 0.0500 0.443 0.583
## 29 56 Study 2 Women's reproductive … Low … ABscale… 0.584 0.0654 0.492 0.676
## 30 56 Study 2 Women's reproductive … Sing… ABscale… 0.528 0.0679 0.432 0.624
## 31 56 Study 2 Women's reproductive … Marr… ABscale… 0.553 0.0692 0.455 0.650
## 32 56 Study 2 Men's reproductive au… Fair… FinAb_2x 0.535 0.0513 0.463 0.607
## 33 56 Study 2 Men's reproductive au… Men … FinAb_4x 0.448 0.0506 0.377 0.519
## 34 56 Study 2 Men's reproductive au… Man … FinAb_3x 0.417 0.0579 0.336 0.499
## 35 56 Study 2 Men's reproductive au… Fath… FinAb_1x 0.478 0.0544 0.402 0.555
## 36 56 Pooled Women's reproductive … Low … ABscale… 0.593 0.0430 0.533 0.653
## 37 56 Pooled Women's reproductive … Sing… ABscale… 0.578 0.0446 0.515 0.640
## 38 56 Pooled Women's reproductive … Marr… ABscale… 0.584 0.0439 0.523 0.645
## 39 56 Pooled Men's reproductive au… Fair… FinAb_2x 0.572 0.0342 0.524 0.620
## 40 56 Pooled Men's reproductive au… Men … FinAb_4x 0.574 0.0367 0.523 0.625
## 41 56 Pooled Men's reproductive au… Man … FinAb_3x 0.537 0.0385 0.483 0.591
## 42 56 Pooled Men's reproductive au… Fath… FinAb_1x 0.496 0.0368 0.444 0.547
## 43 456 Study 1 Women's reproductive … Low … ABscale… 0.649 0.0386 0.595 0.703
## 44 456 Study 1 Women's reproductive … Sing… ABscale… 0.637 0.0405 0.580 0.693
## 45 456 Study 1 Women's reproductive … Marr… ABscale… 0.637 0.0382 0.583 0.690
## 46 456 Study 1 Men's reproductive au… Fair… FinAb_2x 0.554 0.0342 0.507 0.602
## 47 456 Study 1 Men's reproductive au… Men … FinAb_4x 0.633 0.0368 0.581 0.684
## 48 456 Study 1 Men's reproductive au… Man … FinAb_3x 0.577 0.0369 0.526 0.629
## 49 456 Study 1 Men's reproductive au… Fath… FinAb_1x 0.504 0.0369 0.452 0.555
## 50 456 Study 2 Women's reproductive … Low … ABscale… 0.645 0.0447 0.583 0.708
## 51 456 Study 2 Women's reproductive … Sing… ABscale… 0.601 0.0466 0.536 0.666
## 52 456 Study 2 Women's reproductive … Marr… ABscale… 0.619 0.0467 0.553 0.684
## 53 456 Study 2 Men's reproductive au… Fair… FinAb_2x 0.479 0.0367 0.428 0.530
## 54 456 Study 2 Men's reproductive au… Men … FinAb_4x 0.360 0.0373 0.308 0.412
## 55 456 Study 2 Men's reproductive au… Man … FinAb_3x 0.354 0.0402 0.298 0.410
## 56 456 Study 2 Men's reproductive au… Fath… FinAb_1x 0.462 0.0379 0.409 0.514
## 57 456 Pooled Women's reproductive … Low … ABscale… 0.647 0.0298 0.606 0.689
## 58 456 Pooled Women's reproductive … Sing… ABscale… 0.618 0.0312 0.574 0.661
## 59 456 Pooled Women's reproductive … Marr… ABscale… 0.627 0.0306 0.584 0.669
## 60 456 Pooled Men's reproductive au… Fair… FinAb_2x 0.514 0.0254 0.479 0.549
## 61 456 Pooled Men's reproductive au… Men … FinAb_4x 0.487 0.0282 0.448 0.526
## 62 456 Pooled Men's reproductive au… Man … FinAb_3x 0.458 0.0287 0.418 0.498
## 63 456 Pooled Men's reproductive au… Fath… FinAb_1x 0.481 0.0265 0.444 0.518
theme.z <- theme(
axis.text.x = element_text(size = 15, color = "black", margin = margin(t = 5,b = 5), hjust = c(0,1)),
axis.text.y = element_text(size = 15, color = "black", margin = margin(l = 5,r = 5)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.background = element_rect(linewidth = 1.0, color = "black", fill = "gray80", linetype = "solid"),
panel.border = element_rect(linewidth = 1.0, color = "black", fill = NA , linetype = "solid"),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
panel.spacing.x = unit(1, "lines"),
panel.spacing.y = unit(1, "lines"),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 10, hjust = 0, margin = margin(t = 8)),
plot.margin = unit(c(0.5,0.05,0,0.05),"cm"),
plot.subtitle = element_text(size = 15, hjust = 0.5, margin = margin(b = 7)),
plot.title = element_text(size = 18, hjust = 0.5, face = "bold", margin = margin(t = 0,b = 8)),
strip.background = element_rect(linewidth = 1.0, color = "black", fill = "black"),
strip.text.x = element_text(size = 15, color = "white", face = "bold", margin = margin(t = 5,b = 5)),
strip.text.y = element_blank()
)
DATA$ITEM <- factor(DATA$ITEM , levels = rev(unique(DATA$ITEM)))
DATA$STUDY <- factor(DATA$STUDY, levels = unique(DATA$STUDY))
DATA$GENDER <- factor(DATA$GENDER, levels = unique(DATA$GENDER))
DATA.6 <- filter(DATA, LIBERT == 6)
DATA.56 <- filter(DATA, LIBERT == 56)
DATA.456 <- filter(DATA, LIBERT == 456)
PLOT.6 <- ggplot(data = DATA.6, mapping = aes(x = PE, y = ITEM)) +
facet_grid(GENDER ~ STUDY, space = "free_y", scales = "free_y") +
geom_rect(data = NULL, mapping = aes(xmin = 0,xmax = 0.5, ymin = -Inf, ymax = Inf), fill = "gray90") +
geom_point(size = 3.5) +
geom_errorbarh(mapping = aes(xmin = CILO, xmax = CIHI), height = 0, size = 0.75) +
scale_x_continuous(breaks = c(0,1), limits = c(0,1), labels = c("Least\nSupport", "Most\nSupport"), expand = c(0,0)) +
labs(title = "Libertarian identification of 6") +
theme.z +
theme(axis.text.x = element_blank())
PLOT.56 <- ggplot(data = DATA.56, mapping = aes(x = PE, y = ITEM)) +
facet_grid(GENDER ~ STUDY, space = "free_y", scales = "free_y") +
geom_rect(data = NULL, mapping = aes(xmin = 0,xmax = 0.5, ymin = -Inf, ymax = Inf), fill = "gray90") +
geom_point(size = 3.5) +
geom_errorbarh(mapping = aes(xmin = CILO, xmax = CIHI), height = 0, size = 0.75) +
scale_x_continuous(breaks = c(0,1), limits = c(0,1), labels = c("Least\nSupport", "Most\nSupport"), expand = c(0,0)) +
labs(title = "Libertarian identification of 5 or 6") +
theme.z +
theme(axis.text.x = element_blank(),
strip.text.x = element_blank())
PLOT.456 <- ggplot(data = DATA.456, mapping = aes(x = PE, y = ITEM)) +
facet_grid(GENDER ~ STUDY, space = "free_y", scales = "free_y") +
geom_rect(data = NULL, mapping = aes(xmin = 0,xmax = 0.5, ymin = -Inf, ymax = Inf), fill = "gray90") +
geom_point(size = 3.5) +
geom_errorbarh(mapping = aes(xmin = CILO, xmax = CIHI), height = 0, size = 0.75) +
scale_x_continuous(breaks = c(0,1), limits = c(0,1), labels = c("Least\nSupport", "Most\nSupport"), expand = c(0,0)) +
labs(title = "Libertarian identification of 4, 5, or 6") +
theme.z +
theme(strip.text.x = element_blank())
PLOT.6 + PLOT.56 + PLOT.456 + plot_layout(ncol = 1)
library(tidyverse)
DATA <- tribble(
~RESPONSE ,~GROUP , ~PE ,
"Rated only men cold" ,"U.S. adults" , 0.111665 ,
"Rated only men cold" ,"Biden voters", 0.1721875,
"Rated only men cold" ,"Trump voters", 0.0515194,
"Residual colder to men" ,"U.S. adults" , 0.4547139,
"Residual colder to men" ,"Biden voters", 0.5282067,
"Residual colder to men" ,"Trump voters", 0.410322,
"Rated men equal to women","U.S. adults" , 0.2260411,
"Rated men equal to women","Biden voters", 0.1299536,
"Rated men equal to women","Trump voters", 0.3142311,
"Residual colder to women","U.S. adults" , 0.176867,
"Residual colder to women","Biden voters", 0.1426348,
"Residual colder to women","Trump voters", 0.198812,
"Rated only women cold" ,"U.S. adults" , 0.0301996,
"Rated only women cold" ,"Biden voters", 0.0255463,
"Rated only women cold" ,"Trump voters", 0.0251155)
DATA$RESPONSE <- factor(DATA$RESPONSE, levels = rev(unique(DATA$RESPONSE)))
DATA$GROUP <- factor(DATA$GROUP , levels = unique(DATA$GROUP[1:3]))
theme.z <- theme(
axis.text.x = element_text(color = "black", size = 15, margin = margin(t = 0)),
axis.text.y = element_text(color = "black", size = 15, margin = margin(l = 0, r = 0)),
axis.text.y.right = element_text(color = "black", size = 15, margin = margin(l = 0, r = 0)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
legend.position = "none",
legend.spacing.x = unit(10, "pt"),
legend.spacing.y = unit(10, "pt"),
legend.text = element_text(size = 15, margin = margin(t = 5)),
legend.title = element_text(size = 15, face = "bold"),
panel.background = element_rect(fill = "white"),
panel.border = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.caption = element_text(size = 11, hjust = 0, margin = margin(15,0,0,0)),
plot.subtitle = element_text(hjust = 0.5),
plot.margin = unit(c(t = 10,r = 10,b = 10,l = 10),"pt"),
plot.title = element_text(face = "bold", margin = margin(t = 0, b = 6), size = 20, hjust = 0.5)
)
CAPTION <- str_wrap("Note: Cold refers to a rating under 50. Colder refers to a lower rating. Estimates are weighted. \nSample size 1,500 U.S. adults, 607 Biden voters, 508 Democrats, 428 Independents, and 430 Republicans, with a non-response from 1 Democrat / Biden voter.\nData source: American National Election Studies. 2022. ANES 2022 Pilot Study [dataset and documentation].\nDecember 14, 2022 version. www.electionstudies.org. Used presvote20post for the vote variable.", width = 100)
ggplot(DATA, mapping = aes(fill = RESPONSE, y = 100*PE, x = GROUP)) +
geom_col(color = "black", linewidth = 1.1, width = 0.85) +
scale_fill_manual(values = rev(c("Rated only men cold" = "steelblue1","Residual colder to men" = "powderblue","Rated men equal to women" = "white","Residual colder to women" = "lightpink1","Rated only women cold" = "deeppink1")), name = "Category") +
scale_y_continuous(limits = c(0,100.01), breaks = seq(0,100,by = 10), sec.axis = sec_axis(~.,breaks = c(3,27,62,86,98), label = c("Rated only men cold","Residual colder to men","Rated men equal to women","Residual colder to women","Rated only women cold"))) +
labs(title = "Ratings about men and women\non 0-to-100 feeling thermometers", caption = CAPTION) +
theme.z
This next plot is a column plot but with categories stacked on top of each other.
library(tidyverse)
DATA <- tribble(
~GROUP , ~ITEM , ~PE ,
"Democrats" , "Not at all" , 0.775,
"Democrats" , "A little" , 0.098,
"Democrats" , "A moderate amount", 0.077,
"Democrats" , "A lot" , 0.026,
"Democrats" , "A great deal" , 0.018,
"Republicans" , "Not at all" , 0.893,
"Republicans" , "A little" , 0.03 ,
"Republicans" , "A moderate amount", 0.047,
"Republicans" , "A lot" , 0.012,
"Republicans" , "A great deal" , 0.015,
"Independents", "Not at all" , 0.829,
"Independents", "A little" , 0.072,
"Independents", "A moderate amount", 0.064,
"Independents", "A lot" , 0.01 ,
"Independents", "A great deal" , 0.013)
DATA$ITEM <- factor(DATA$ITEM, levels = c("Not at all", "A little", "A moderate amount", "A lot", "A great deal"))
CAPTION <- str_wrap("Data source: American National Election Studies. 2021.\nANES 2020 Time Series Study Preliminary Release:\nPre-Election Data [dataset and documentation]. February 11, 2021\nversion. www.electionstudies.org.\n\nSample sizes: Democrats 2,683. Independents 2,525. Republicans 2,563.", width = 97)
theme.z <- theme(
axis.text.x = element_text(size = 15, color = "black", hjust = 0.5, margin = margin(t = 8,b = 8)),
axis.text.y = element_text(size = 15, color = "black", vjust = 0.5, margin = margin(r = 8,l = 8)),
axis.text.y.right = element_text(size = 15, color = "black", vjust = 0.5, margin = margin(r = 8,l = 8)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_text(size = 15, color = "black", vjust = 0.5, margin = margin(r = 4), angle = 0),
axis.title.y.right = element_text(size = 15, color = "black", vjust = 0.5, margin = margin(l = 4), angle = 0),
legend.position = "right",
legend.spacing.x = unit(10, "pt"),
legend.spacing.y = unit(10, "pt"),
legend.text = element_text(size = 15, margin = margin(t = 5, r = 5, b = 5, l = 5)),
legend.title = element_text(size = 15, face = "bold"),
panel.background = element_rect(fill = "gray90"),
panel.border = element_rect(linewidth = 1.0, color = "black", fill = NA),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_line(linewidth = 0.1, color = "gray70", linetype = "solid"),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.caption = element_text(size = 12, hjust = 0 , margin = margin(t = 10)),
plot.margin = unit(c(t = 10,r = 10,b = 10,l = 10), "pt"),
plot.subtitle = element_text(size = 15, hjust = 0.5, margin = margin(b = 7)),
plot.title = element_text(size = 19, hjust = 0.5, face = "bold", margin = margin(t = 0,b = 15))
)
ggplot(DATA, mapping = aes(fill = ITEM, y = 100*PE, x = GROUP)) +
geom_col(color = "black", linewidth = 1.1, width = 0.85) +
scale_fill_manual(values = rev(c("red4","red3","red","pink","white")), name = "Response") +
scale_x_discrete(limits = c("Democrats","Independents","Republicans")) +
scale_y_continuous(limits = c(0,100), breaks = seq(0,100,by = 10), sec.axis = dup_axis()) +
labs(title = "How much do you feel it is justified\nfor people to use violence to pursue\ntheir political goals in this country?", y = "%", caption = CAPTION) +
theme.z
This plot provides an example of data loaded from an external file. The line “DATA <- read_csv(”Figure 6.CSV”)” gets the CSV file from the working directory, but the line “DATA <- read_csv(file.choose())” can be used to open a dialog box so that you can navigate to a folder to select the file. This is a figure from Zigerell 2022 “Introducing Political Science Students to Data Visualization Strategies” in the Journal of Political Science Education.
library(grid)
library(tidyverse)
DATA <- read_csv("Figure 6.CSV")
print(DATA, n = Inf)
## # A tibble: 22 × 5
## EVENT DATE FACET PE N
## <chr> <chr> <chr> <dbl> <dbl>
## 1 Launches campaign 2015 Jun 16 Serious -7 57
## 2 First GOP debate 2015 Aug 6 Serious -5 89
## 3 Call for Muslim ban 2015 Dec 7 Serious -16 99
## 4 Loses Iowa 2016 Feb 1 Serious -10 115
## 5 Super Tuesday 2016 Mar 15 Serious -28 155
## 6 Cruz and Kasich exit 2016 May 3 Serious -45 170
## 7 Delegate threshold 2016 May 26 Serious -16 125
## 8 Attacks Gold Star family 2016 Aug 1 Serious -36 144
## 9 First presidential debate 2016 Sep 26 Serious -46 268
## 10 Hot mic tape released 2016 Oct 7 Serious -47 180
## 11 Comey's letter 2016 Oct 28 Serious -11 115
## 12 Launches campaign 2015 Jun 16 Clown 16 57
## 13 First GOP debate 2015 Aug 6 Clown 11 89
## 14 Call for Muslim ban 2015 Dec 7 Clown 9 99
## 15 Loses Iowa 2016 Feb 1 Clown 17 115
## 16 Super Tuesday 2016 Mar 15 Clown 16 155
## 17 Cruz and Kasich exit 2016 May 3 Clown 22 170
## 18 Delegate threshold 2016 May 26 Clown 26 125
## 19 Attacks Gold Star family 2016 Aug 1 Clown 21 144
## 20 First presidential debate 2016 Sep 26 Clown 69 268
## 21 Hot mic tape released 2016 Oct 7 Clown 20 180
## 22 Comey's letter 2016 Oct 28 Clown 12 115
DATA$PCT <- DATA$PE / DATA$N
DATA$EVENT <- factor(DATA$EVENT, levels = DATA$EVENT[1:11])
DATA$FACET <- factor(DATA$FACET, levels = c("Serious","Clown"))
TEXT.SERIOUS <- textGrob(expression(bold("Serious")), gp = gpar(fontsize = 21))
TEXT.CLOWN <- textGrob(expression(bold("Clown" )), gp = gpar(fontsize = 21))
CAPTION <- str_wrap("Note: Respective samples sizes were 57, 89, 99, 115, 155, 170, 125, 144, 268, 180, and 115. Data source: Boydstun and Lawrence (2019).", width = 50)
theme.z <- theme(
axis.text.x = element_text(size = 15, color = "black", margin = margin(t = 10,r = 10,b = 10,l = 10)),
axis.text.x.top = element_blank(),
axis.text.x.bottom = element_text(size = 15, color = "black", margin = margin(t = 10,r = 10,b = 10,l = 10)),
axis.text.y = element_text(size = 15, color = "black", margin = margin(t = 10,r = 10,b = 10,l = 10)),
axis.text.y.right = element_text(size = 15, color = "black", margin = margin(t = 10,r = 10,b = 10,l = 10)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_text(size = 15, color = "black", margin = margin(t = 0,r = 10,b = 10,l = 10)),
axis.title.y = element_blank(),
legend.position = "none",
panel.background = element_rect(linewidth = 0.5, color = "black", fill = "gray90", linetype = "solid"),
panel.border = element_rect(linewidth = 1.2, color = "black", fill = NA , linetype = "solid"),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 12, hjust = 0 , margin = margin(t = 10)),
plot.margin = unit(c(t = 50,r = 5,b = 5,l = 5),"pt"),
plot.subtitle = element_text(size = 15, hjust = 0.5, margin = margin(b = 7)),
plot.title = element_text(size = 20, hjust = 0.5, face = "bold", margin = margin(t = 0,b = 35)),
strip.background = element_rect(linewidth = 1, color = "black", fill = "black"),
strip.text.x = element_text(size = 18, color = "white", face = "bold", margin = margin(t = 7.5,b = 7.5))
)
ggplot(data = DATA, mapping = aes(x = rev(as.numeric(EVENT)), y = 100*PCT, fill = FACET)) +
coord_flip(clip = "off") +
scale_fill_manual(values = c("purple","orange"), breaks = c("Serious","Clown"), labels = c("Serious","Clown")) +
geom_col(linewidth = 0.85, width = 0.7, color = "black") +
scale_x_continuous(breaks = 1:11, labels = rev(DATA$EVENT[1:11]),
sec.axis = sec_axis(~.,breaks = 1:11, labels = rev(DATA$DATE[1:11]))) +
scale_y_continuous(limits = c(-30,30), breaks = seq(-30,30,10), labels = c("30%","20%","10%","0%","10%","20%","30%")) +
labs(y = "Percentage of all articles", caption = CAPTION) +
annotation_custom(TEXT.SERIOUS, xmin = 12.75, xmax = 12.75, ymin = -15, ymax = -15) +
annotation_custom(TEXT.CLOWN , xmin = 12.75, xmax = 12.75, ymin = 15, ymax = 15) +
theme.z
This is a figure from Zigerell 2022 “Introducing Political Science Students to Data Visualization Strategies” in the Journal of Political Science Education.
library(grid)
library(tidyverse)
DATA <- tribble(
~EVENT , ~DATE , ~PE.SERIOUS, ~PE.CLOWN, ~N ,
"Launches campaign" , "2015 Jun 16", -7, 16, 57,
"First GOP debate" , "2015 Aug 6" , -5, 11, 89,
"Call for Muslim ban" , "2015 Dec 7" , -16, 9, 99,
"Loses Iowa" , "2016 Feb 1" , -10, 17, 115,
"Super Tuesday" , "2016 Mar 15", -28, 16, 155,
"Cruz and Kasich exit" , "2016 May 3" , -45, 22, 170,
"Delegate threshold" , "2016 May 26", -16, 26, 125,
"Attacks Gold Star family" , "2016 Aug 1" , -36, 21, 144,
"First presidential debate", "2016 Sep 26", -46, 69, 268,
"Hot mic tape released" , "2016 Oct 7" , -47, 20, 180,
"Comey's letter" , "2016 Oct 28", -11, 12, 115)
DATA$PCT <- DATA$PE.SERIOUS / DATA$N
DATA$EVENT <- factor(DATA$EVENT, levels = DATA$EVENT[1:11])
EVENT.AN <- as.numeric(DATA$EVENT)
TEXT.SERIOUS <- textGrob(expression(bold("Serious")), gp = gpar(fontsize = 21))
TEXT.CLOWN <- textGrob(expression(bold("Clown" )), gp = gpar(fontsize = 21))
CAPTION <- str_wrap("Note: Respective samples sizes were 57, 89, 99, 115, 155, 170, 125, 144, 268, 180, and 115. Data source: Boydstun and Lawrence (2019).", width = 50)
theme.z <- theme(
axis.text.x = element_blank(),
axis.text.x.top = element_blank(),
axis.text.y = element_text(size = 15 , color = "black", margin = margin(t = 10,r = 10,b = 10,l = 10)),
axis.text.y.right = element_text(size = 15 , color = "black", margin = margin(t = 10,r = 10,b = 10,l = 10)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_text(size = 15 , color = "black", margin = margin(t = 10,r = 10,b = 10,l = 10)),
axis.title.y = element_blank(),
legend.position = "none",
panel.background = element_rect(linewidth = 0.5, color = "black", fill = "gray90", linetype = "solid"),
panel.border = element_rect(linewidth = 1.2, color = "black", fill = NA , linetype = "solid"),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 12 , hjust = 0 , margin = margin(t = 10)),
plot.margin = unit(c(t = 50,r = 5,b = 5,l = 5),"pt"),
plot.subtitle = element_text(size = 15 , hjust = 0.5),
plot.title = element_text(size = 20 , hjust = 0.5, margin = margin(t = 0,b = 35), face = "bold"),
strip.background = element_rect(linewidth = 1, color = "black", fill = "black"),
strip.text.x = element_text(size = 18, color = "white", face = "bold", margin = margin(t = 7.5,b = 7.5))
)
ggplot(data = DATA, mapping = aes(x = rev(EVENT.AN), y = 100*PCT)) +
coord_flip(clip = "off") +
scale_fill_manual(values = c("purple")) +
geom_col(color = "black", linewidth = 0.85, width = 0.7, fill = "purple") +
geom_segment(x = rev(EVENT.AN), xend = rev(EVENT.AN), y = 0, yend = 100*DATA$PE.CLOWN/DATA$N) +
geom_point(y = 100*DATA$PE.CLOWN/DATA$N, x = rev(EVENT.AN), shape = 21, size = 4.5, color = "black", fill = "orange", stroke = 1.25) +
geom_text(mapping = aes(x = rev(EVENT.AN), y = c(100*PCT), label = scales::percent(abs(PCT), accuracy = 1L)) , hjust = 1, size = c(rep_len(5,11)), nudge_y = c(rep_len(-3,11))) +
geom_text(mapping = aes(x = rev(EVENT.AN), y = 45 , label = scales::percent(abs(PE.CLOWN/N), accuracy = 1L)), hjust = 1, size = c(rep_len(5,11))) +
scale_x_continuous(breaks = 1:11, labels = rev(DATA$EVENT[1:11]), sec.axis = sec_axis(~.,breaks = 1:11, labels = rev(DATA$DATE[1:11]))) +
scale_y_continuous(limits = c(-45,45)) +
annotation_custom(TEXT.SERIOUS, xmin = 12.75, xmax = 12.75, ymin = -22.5, ymax = -22.5) +
annotation_custom(TEXT.CLOWN , xmin = 12.75, xmax = 12.75, ymin = 22.5, ymax = 22.5) +
labs(y = "Percentage of all articles", caption = CAPTION) +
theme.z
library(tidyverse)
DATA <- read_csv("VOTER immig.csv")
print(DATA, n = Inf)
## # A tibble: 5,900 × 1
## ft_immig_2020Sep
## <dbl>
## 1 89
## 2 88
## 3 91
## 4 96
## 5 81
## 6 76
## 7 60
## 8 80
## 9 78
## 10 29
## 11 50
## 12 100
## 13 77
## 14 997
## 15 92
## 16 21
## 17 100
## 18 100
## 19 50
## 20 60
## 21 74
## 22 50
## 23 91
## 24 62
## 25 51
## 26 1
## 27 70
## 28 100
## 29 50
## 30 96
## 31 99
## 32 88
## 33 91
## 34 99
## 35 99
## 36 90
## 37 50
## 38 61
## 39 91
## 40 100
## 41 50
## 42 84
## 43 99
## 44 73
## 45 63
## 46 96
## 47 50
## 48 92
## 49 49
## 50 70
## 51 85
## 52 49
## 53 80
## 54 100
## 55 98
## 56 68
## 57 100
## 58 41
## 59 50
## 60 93
## 61 55
## 62 78
## 63 75
## 64 50
## 65 52
## 66 92
## 67 77
## 68 3
## 69 34
## 70 49
## 71 66
## 72 100
## 73 1
## 74 78
## 75 95
## 76 92
## 77 90
## 78 72
## 79 71
## 80 65
## 81 60
## 82 75
## 83 90
## 84 75
## 85 100
## 86 51
## 87 52
## 88 50
## 89 80
## 90 50
## 91 74
## 92 75
## 93 98
## 94 45
## 95 51
## 96 99
## 97 75
## 98 66
## 99 60
## 100 52
## 101 90
## 102 50
## 103 99
## 104 75
## 105 51
## 106 43
## 107 70
## 108 99
## 109 56
## 110 29
## 111 91
## 112 72
## 113 83
## 114 85
## 115 50
## 116 90
## 117 99
## 118 11
## 119 75
## 120 99
## 121 50
## 122 80
## 123 90
## 124 60
## 125 49
## 126 41
## 127 99
## 128 70
## 129 51
## 130 77
## 131 74
## 132 88
## 133 69
## 134 96
## 135 40
## 136 100
## 137 59
## 138 52
## 139 76
## 140 77
## 141 91
## 142 50
## 143 997
## 144 80
## 145 51
## 146 85
## 147 3
## 148 50
## 149 81
## 150 46
## 151 78
## 152 96
## 153 84
## 154 50
## 155 74
## 156 52
## 157 86
## 158 92
## 159 70
## 160 50
## 161 50
## 162 50
## 163 71
## 164 997
## 165 78
## 166 10
## 167 99
## 168 95
## 169 65
## 170 60
## 171 49
## 172 86
## 173 60
## 174 86
## 175 31
## 176 50
## 177 99
## 178 51
## 179 75
## 180 60
## 181 59
## 182 100
## 183 65
## 184 25
## 185 90
## 186 95
## 187 90
## 188 55
## 189 100
## 190 80
## 191 100
## 192 91
## 193 50
## 194 50
## 195 60
## 196 51
## 197 94
## 198 94
## 199 51
## 200 76
## 201 88
## 202 997
## 203 70
## 204 74
## 205 29
## 206 94
## 207 53
## 208 58
## 209 96
## 210 100
## 211 77
## 212 55
## 213 25
## 214 63
## 215 81
## 216 79
## 217 91
## 218 83
## 219 90
## 220 75
## 221 50
## 222 52
## 223 48
## 224 81
## 225 90
## 226 49
## 227 81
## 228 91
## 229 50
## 230 80
## 231 99
## 232 10
## 233 50
## 234 73
## 235 100
## 236 70
## 237 80
## 238 51
## 239 6
## 240 92
## 241 50
## 242 96
## 243 100
## 244 79
## 245 100
## 246 70
## 247 100
## 248 95
## 249 78
## 250 8
## 251 81
## 252 95
## 253 0
## 254 64
## 255 75
## 256 83
## 257 40
## 258 58
## 259 51
## 260 82
## 261 87
## 262 89
## 263 76
## 264 10
## 265 99
## 266 50
## 267 77
## 268 997
## 269 997
## 270 85
## 271 100
## 272 68
## 273 70
## 274 15
## 275 89
## 276 100
## 277 80
## 278 70
## 279 100
## 280 80
## 281 66
## 282 50
## 283 59
## 284 90
## 285 15
## 286 78
## 287 73
## 288 65
## 289 84
## 290 72
## 291 80
## 292 54
## 293 78
## 294 90
## 295 47
## 296 997
## 297 53
## 298 100
## 299 51
## 300 6
## 301 997
## 302 90
## 303 52
## 304 49
## 305 83
## 306 99
## 307 50
## 308 76
## 309 90
## 310 82
## 311 51
## 312 37
## 313 90
## 314 90
## 315 80
## 316 50
## 317 77
## 318 49
## 319 90
## 320 80
## 321 50
## 322 77
## 323 81
## 324 60
## 325 50
## 326 61
## 327 74
## 328 81
## 329 83
## 330 100
## 331 6
## 332 80
## 333 21
## 334 73
## 335 53
## 336 95
## 337 58
## 338 93
## 339 100
## 340 78
## 341 100
## 342 64
## 343 100
## 344 62
## 345 70
## 346 95
## 347 85
## 348 49
## 349 80
## 350 81
## 351 25
## 352 79
## 353 50
## 354 78
## 355 68
## 356 100
## 357 997
## 358 95
## 359 100
## 360 75
## 361 100
## 362 49
## 363 80
## 364 85
## 365 31
## 366 79
## 367 69
## 368 2
## 369 76
## 370 84
## 371 100
## 372 52
## 373 87
## 374 80
## 375 81
## 376 73
## 377 61
## 378 77
## 379 63
## 380 80
## 381 95
## 382 94
## 383 78
## 384 100
## 385 59
## 386 81
## 387 99
## 388 69
## 389 60
## 390 51
## 391 99
## 392 90
## 393 54
## 394 99
## 395 91
## 396 90
## 397 100
## 398 50
## 399 88
## 400 72
## 401 70
## 402 79
## 403 78
## 404 94
## 405 61
## 406 95
## 407 50
## 408 49
## 409 96
## 410 50
## 411 75
## 412 50
## 413 50
## 414 94
## 415 90
## 416 89
## 417 50
## 418 90
## 419 79
## 420 80
## 421 91
## 422 97
## 423 85
## 424 54
## 425 100
## 426 50
## 427 50
## 428 99
## 429 49
## 430 60
## 431 90
## 432 69
## 433 10
## 434 22
## 435 74
## 436 37
## 437 83
## 438 65
## 439 50
## 440 82
## 441 99
## 442 52
## 443 99
## 444 100
## 445 63
## 446 100
## 447 75
## 448 31
## 449 70
## 450 48
## 451 81
## 452 51
## 453 53
## 454 69
## 455 65
## 456 81
## 457 81
## 458 75
## 459 100
## 460 40
## 461 70
## 462 99
## 463 85
## 464 100
## 465 61
## 466 93
## 467 40
## 468 99
## 469 75
## 470 50
## 471 51
## 472 65
## 473 100
## 474 0
## 475 66
## 476 50
## 477 100
## 478 74
## 479 100
## 480 89
## 481 50
## 482 60
## 483 50
## 484 100
## 485 70
## 486 69
## 487 80
## 488 75
## 489 50
## 490 61
## 491 93
## 492 90
## 493 19
## 494 2
## 495 20
## 496 89
## 497 55
## 498 100
## 499 60
## 500 80
## 501 100
## 502 6
## 503 96
## 504 50
## 505 98
## 506 95
## 507 60
## 508 94
## 509 81
## 510 40
## 511 60
## 512 76
## 513 60
## 514 51
## 515 53
## 516 81
## 517 75
## 518 55
## 519 61
## 520 81
## 521 100
## 522 83
## 523 0
## 524 100
## 525 75
## 526 51
## 527 85
## 528 62
## 529 96
## 530 15
## 531 76
## 532 50
## 533 100
## 534 72
## 535 80
## 536 51
## 537 79
## 538 83
## 539 997
## 540 55
## 541 82
## 542 100
## 543 84
## 544 99
## 545 66
## 546 99
## 547 51
## 548 40
## 549 97
## 550 51
## 551 90
## 552 77
## 553 62
## 554 97
## 555 58
## 556 94
## 557 43
## 558 100
## 559 74
## 560 85
## 561 100
## 562 48
## 563 80
## 564 50
## 565 88
## 566 94
## 567 50
## 568 72
## 569 85
## 570 90
## 571 78
## 572 71
## 573 92
## 574 52
## 575 84
## 576 80
## 577 82
## 578 95
## 579 88
## 580 10
## 581 50
## 582 5
## 583 96
## 584 75
## 585 95
## 586 71
## 587 49
## 588 11
## 589 81
## 590 100
## 591 52
## 592 67
## 593 88
## 594 99
## 595 90
## 596 49
## 597 91
## 598 95
## 599 11
## 600 91
## 601 94
## 602 71
## 603 47
## 604 50
## 605 79
## 606 52
## 607 100
## 608 76
## 609 76
## 610 51
## 611 67
## 612 100
## 613 50
## 614 43
## 615 50
## 616 79
## 617 88
## 618 59
## 619 78
## 620 99
## 621 75
## 622 50
## 623 100
## 624 99
## 625 50
## 626 90
## 627 52
## 628 95
## 629 50
## 630 31
## 631 99
## 632 60
## 633 80
## 634 82
## 635 99
## 636 0
## 637 50
## 638 60
## 639 25
## 640 22
## 641 76
## 642 43
## 643 75
## 644 997
## 645 50
## 646 63
## 647 12
## 648 90
## 649 100
## 650 97
## 651 53
## 652 997
## 653 91
## 654 90
## 655 60
## 656 91
## 657 80
## 658 65
## 659 86
## 660 78
## 661 80
## 662 60
## 663 47
## 664 92
## 665 70
## 666 80
## 667 50
## 668 80
## 669 70
## 670 51
## 671 79
## 672 49
## 673 96
## 674 21
## 675 30
## 676 81
## 677 50
## 678 71
## 679 50
## 680 61
## 681 74
## 682 92
## 683 95
## 684 87
## 685 57
## 686 30
## 687 100
## 688 71
## 689 49
## 690 56
## 691 997
## 692 50
## 693 22
## 694 50
## 695 60
## 696 89
## 697 83
## 698 79
## 699 60
## 700 69
## 701 997
## 702 29
## 703 33
## 704 23
## 705 62
## 706 97
## 707 99
## 708 84
## 709 50
## 710 64
## 711 25
## 712 70
## 713 72
## 714 87
## 715 50
## 716 60
## 717 94
## 718 94
## 719 1
## 720 50
## 721 88
## 722 41
## 723 50
## 724 51
## 725 81
## 726 62
## 727 19
## 728 47
## 729 55
## 730 83
## 731 51
## 732 997
## 733 80
## 734 80
## 735 64
## 736 75
## 737 997
## 738 50
## 739 78
## 740 90
## 741 2
## 742 13
## 743 79
## 744 85
## 745 63
## 746 100
## 747 50
## 748 1
## 749 60
## 750 75
## 751 73
## 752 51
## 753 50
## 754 100
## 755 17
## 756 94
## 757 76
## 758 79
## 759 78
## 760 66
## 761 79
## 762 1
## 763 2
## 764 3
## 765 56
## 766 93
## 767 41
## 768 15
## 769 83
## 770 61
## 771 77
## 772 48
## 773 67
## 774 21
## 775 65
## 776 50
## 777 80
## 778 94
## 779 100
## 780 66
## 781 17
## 782 71
## 783 67
## 784 20
## 785 76
## 786 81
## 787 81
## 788 50
## 789 60
## 790 39
## 791 84
## 792 60
## 793 50
## 794 54
## 795 74
## 796 49
## 797 89
## 798 7
## 799 997
## 800 10
## 801 82
## 802 63
## 803 100
## 804 82
## 805 99
## 806 63
## 807 79
## 808 75
## 809 91
## 810 50
## 811 57
## 812 66
## 813 50
## 814 997
## 815 10
## 816 38
## 817 60
## 818 50
## 819 59
## 820 75
## 821 91
## 822 50
## 823 50
## 824 1
## 825 0
## 826 1
## 827 52
## 828 6
## 829 50
## 830 100
## 831 69
## 832 98
## 833 27
## 834 25
## 835 100
## 836 28
## 837 71
## 838 59
## 839 50
## 840 77
## 841 99
## 842 96
## 843 49
## 844 71
## 845 87
## 846 1
## 847 3
## 848 4
## 849 37
## 850 50
## 851 74
## 852 74
## 853 49
## 854 80
## 855 20
## 856 76
## 857 54
## 858 52
## 859 997
## 860 0
## 861 1
## 862 11
## 863 78
## 864 49
## 865 2
## 866 60
## 867 100
## 868 80
## 869 7
## 870 40
## 871 60
## 872 74
## 873 49
## 874 77
## 875 84
## 876 86
## 877 92
## 878 100
## 879 50
## 880 1
## 881 65
## 882 79
## 883 50
## 884 79
## 885 96
## 886 51
## 887 91
## 888 85
## 889 100
## 890 30
## 891 80
## 892 92
## 893 90
## 894 100
## 895 80
## 896 94
## 897 49
## 898 40
## 899 57
## 900 91
## 901 51
## 902 89
## 903 21
## 904 62
## 905 59
## 906 56
## 907 49
## 908 91
## 909 71
## 910 91
## 911 99
## 912 91
## 913 76
## 914 77
## 915 0
## 916 14
## 917 99
## 918 80
## 919 99
## 920 52
## 921 96
## 922 90
## 923 25
## 924 80
## 925 51
## 926 80
## 927 88
## 928 84
## 929 26
## 930 50
## 931 99
## 932 94
## 933 96
## 934 26
## 935 12
## 936 80
## 937 80
## 938 50
## 939 98
## 940 51
## 941 96
## 942 99
## 943 50
## 944 13
## 945 50
## 946 60
## 947 49
## 948 88
## 949 90
## 950 52
## 951 67
## 952 90
## 953 10
## 954 88
## 955 13
## 956 90
## 957 50
## 958 50
## 959 50
## 960 78
## 961 52
## 962 61
## 963 62
## 964 76
## 965 75
## 966 69
## 967 62
## 968 997
## 969 94
## 970 50
## 971 83
## 972 90
## 973 2
## 974 51
## 975 91
## 976 11
## 977 32
## 978 51
## 979 30
## 980 62
## 981 48
## 982 50
## 983 57
## 984 50
## 985 89
## 986 90
## 987 87
## 988 49
## 989 84
## 990 50
## 991 51
## 992 51
## 993 56
## 994 44
## 995 35
## 996 99
## 997 81
## 998 89
## 999 61
## 1000 56
## 1001 75
## 1002 79
## 1003 83
## 1004 81
## 1005 58
## 1006 49
## 1007 11
## 1008 49
## 1009 73
## 1010 93
## 1011 39
## 1012 50
## 1013 997
## 1014 0
## 1015 80
## 1016 61
## 1017 51
## 1018 42
## 1019 100
## 1020 50
## 1021 77
## 1022 95
## 1023 79
## 1024 66
## 1025 75
## 1026 82
## 1027 75
## 1028 90
## 1029 997
## 1030 57
## 1031 59
## 1032 81
## 1033 83
## 1034 89
## 1035 57
## 1036 75
## 1037 90
## 1038 90
## 1039 90
## 1040 62
## 1041 100
## 1042 51
## 1043 40
## 1044 50
## 1045 72
## 1046 80
## 1047 75
## 1048 53
## 1049 38
## 1050 12
## 1051 52
## 1052 100
## 1053 11
## 1054 97
## 1055 76
## 1056 96
## 1057 80
## 1058 82
## 1059 0
## 1060 2
## 1061 71
## 1062 59
## 1063 78
## 1064 75
## 1065 100
## 1066 71
## 1067 96
## 1068 83
## 1069 96
## 1070 8
## 1071 69
## 1072 100
## 1073 51
## 1074 51
## 1075 79
## 1076 100
## 1077 51
## 1078 82
## 1079 51
## 1080 50
## 1081 66
## 1082 91
## 1083 61
## 1084 74
## 1085 76
## 1086 82
## 1087 99
## 1088 82
## 1089 1
## 1090 58
## 1091 99
## 1092 61
## 1093 65
## 1094 48
## 1095 997
## 1096 13
## 1097 90
## 1098 49
## 1099 49
## 1100 80
## 1101 81
## 1102 81
## 1103 71
## 1104 83
## 1105 61
## 1106 50
## 1107 50
## 1108 997
## 1109 77
## 1110 56
## 1111 50
## 1112 9
## 1113 90
## 1114 90
## 1115 91
## 1116 93
## 1117 50
## 1118 71
## 1119 86
## 1120 78
## 1121 81
## 1122 99
## 1123 30
## 1124 36
## 1125 80
## 1126 90
## 1127 50
## 1128 100
## 1129 91
## 1130 88
## 1131 80
## 1132 52
## 1133 94
## 1134 90
## 1135 87
## 1136 31
## 1137 96
## 1138 59
## 1139 91
## 1140 97
## 1141 81
## 1142 92
## 1143 50
## 1144 50
## 1145 72
## 1146 94
## 1147 80
## 1148 71
## 1149 79
## 1150 99
## 1151 70
## 1152 80
## 1153 79
## 1154 76
## 1155 50
## 1156 63
## 1157 50
## 1158 100
## 1159 30
## 1160 96
## 1161 91
## 1162 80
## 1163 100
## 1164 72
## 1165 86
## 1166 997
## 1167 50
## 1168 98
## 1169 71
## 1170 91
## 1171 90
## 1172 66
## 1173 50
## 1174 99
## 1175 99
## 1176 86
## 1177 51
## 1178 50
## 1179 50
## 1180 80
## 1181 50
## 1182 82
## 1183 51
## 1184 51
## 1185 90
## 1186 51
## 1187 81
## 1188 51
## 1189 91
## 1190 26
## 1191 51
## 1192 77
## 1193 997
## 1194 81
## 1195 74
## 1196 22
## 1197 50
## 1198 50
## 1199 99
## 1200 59
## 1201 0
## 1202 100
## 1203 78
## 1204 80
## 1205 95
## 1206 100
## 1207 80
## 1208 75
## 1209 100
## 1210 83
## 1211 46
## 1212 96
## 1213 77
## 1214 96
## 1215 50
## 1216 51
## 1217 98
## 1218 50
## 1219 51
## 1220 52
## 1221 100
## 1222 79
## 1223 90
## 1224 30
## 1225 50
## 1226 50
## 1227 95
## 1228 71
## 1229 997
## 1230 99
## 1231 100
## 1232 98
## 1233 0
## 1234 77
## 1235 84
## 1236 100
## 1237 61
## 1238 97
## 1239 100
## 1240 51
## 1241 75
## 1242 80
## 1243 98
## 1244 997
## 1245 70
## 1246 50
## 1247 997
## 1248 51
## 1249 997
## 1250 76
## 1251 100
## 1252 91
## 1253 86
## 1254 50
## 1255 82
## 1256 78
## 1257 50
## 1258 60
## 1259 65
## 1260 60
## 1261 33
## 1262 997
## 1263 63
## 1264 20
## 1265 82
## 1266 90
## 1267 97
## 1268 40
## 1269 70
## 1270 79
## 1271 91
## 1272 78
## 1273 70
## 1274 86
## 1275 50
## 1276 84
## 1277 79
## 1278 64
## 1279 25
## 1280 27
## 1281 65
## 1282 89
## 1283 52
## 1284 60
## 1285 90
## 1286 50
## 1287 52
## 1288 50
## 1289 1
## 1290 50
## 1291 37
## 1292 1
## 1293 25
## 1294 100
## 1295 30
## 1296 77
## 1297 70
## 1298 21
## 1299 71
## 1300 18
## 1301 17
## 1302 83
## 1303 51
## 1304 77
## 1305 83
## 1306 40
## 1307 80
## 1308 50
## 1309 100
## 1310 50
## 1311 51
## 1312 98
## 1313 58
## 1314 60
## 1315 61
## 1316 75
## 1317 31
## 1318 87
## 1319 51
## 1320 69
## 1321 91
## 1322 51
## 1323 0
## 1324 75
## 1325 89
## 1326 35
## 1327 80
## 1328 92
## 1329 49
## 1330 80
## 1331 50
## 1332 21
## 1333 89
## 1334 40
## 1335 60
## 1336 72
## 1337 91
## 1338 80
## 1339 97
## 1340 85
## 1341 81
## 1342 100
## 1343 100
## 1344 80
## 1345 50
## 1346 50
## 1347 51
## 1348 42
## 1349 92
## 1350 100
## 1351 5
## 1352 100
## 1353 51
## 1354 50
## 1355 51
## 1356 50
## 1357 47
## 1358 84
## 1359 95
## 1360 95
## 1361 95
## 1362 42
## 1363 23
## 1364 91
## 1365 997
## 1366 0
## 1367 11
## 1368 86
## 1369 78
## 1370 50
## 1371 51
## 1372 50
## 1373 22
## 1374 6
## 1375 95
## 1376 51
## 1377 92
## 1378 52
## 1379 45
## 1380 34
## 1381 54
## 1382 53
## 1383 98
## 1384 31
## 1385 90
## 1386 100
## 1387 51
## 1388 85
## 1389 59
## 1390 80
## 1391 78
## 1392 44
## 1393 78
## 1394 50
## 1395 100
## 1396 0
## 1397 83
## 1398 51
## 1399 91
## 1400 997
## 1401 70
## 1402 70
## 1403 51
## 1404 67
## 1405 71
## 1406 70
## 1407 99
## 1408 84
## 1409 59
## 1410 66
## 1411 50
## 1412 85
## 1413 81
## 1414 49
## 1415 100
## 1416 49
## 1417 41
## 1418 75
## 1419 100
## 1420 63
## 1421 77
## 1422 50
## 1423 99
## 1424 71
## 1425 100
## 1426 51
## 1427 99
## 1428 90
## 1429 997
## 1430 46
## 1431 81
## 1432 97
## 1433 5
## 1434 100
## 1435 84
## 1436 77
## 1437 26
## 1438 28
## 1439 997
## 1440 99
## 1441 52
## 1442 100
## 1443 50
## 1444 98
## 1445 79
## 1446 100
## 1447 997
## 1448 84
## 1449 3
## 1450 100
## 1451 6
## 1452 62
## 1453 99
## 1454 90
## 1455 55
## 1456 81
## 1457 61
## 1458 32
## 1459 97
## 1460 66
## 1461 52
## 1462 100
## 1463 80
## 1464 50
## 1465 51
## 1466 78
## 1467 90
## 1468 50
## 1469 74
## 1470 81
## 1471 75
## 1472 71
## 1473 100
## 1474 50
## 1475 68
## 1476 70
## 1477 88
## 1478 100
## 1479 53
## 1480 75
## 1481 100
## 1482 88
## 1483 84
## 1484 51
## 1485 51
## 1486 36
## 1487 50
## 1488 50
## 1489 25
## 1490 70
## 1491 66
## 1492 79
## 1493 23
## 1494 46
## 1495 76
## 1496 87
## 1497 100
## 1498 75
## 1499 71
## 1500 100
## 1501 81
## 1502 76
## 1503 70
## 1504 35
## 1505 50
## 1506 51
## 1507 48
## 1508 47
## 1509 70
## 1510 60
## 1511 80
## 1512 23
## 1513 27
## 1514 80
## 1515 88
## 1516 77
## 1517 98
## 1518 51
## 1519 85
## 1520 88
## 1521 65
## 1522 87
## 1523 92
## 1524 52
## 1525 50
## 1526 50
## 1527 56
## 1528 60
## 1529 50
## 1530 100
## 1531 80
## 1532 81
## 1533 51
## 1534 76
## 1535 91
## 1536 51
## 1537 52
## 1538 50
## 1539 20
## 1540 50
## 1541 80
## 1542 99
## 1543 50
## 1544 50
## 1545 91
## 1546 79
## 1547 90
## 1548 50
## 1549 71
## 1550 44
## 1551 78
## 1552 98
## 1553 94
## 1554 49
## 1555 77
## 1556 44
## 1557 50
## 1558 65
## 1559 53
## 1560 6
## 1561 97
## 1562 6
## 1563 99
## 1564 98
## 1565 25
## 1566 28
## 1567 50
## 1568 44
## 1569 75
## 1570 87
## 1571 99
## 1572 9
## 1573 50
## 1574 997
## 1575 52
## 1576 74
## 1577 997
## 1578 71
## 1579 90
## 1580 19
## 1581 97
## 1582 0
## 1583 92
## 1584 61
## 1585 50
## 1586 98
## 1587 93
## 1588 997
## 1589 47
## 1590 84
## 1591 95
## 1592 49
## 1593 88
## 1594 33
## 1595 30
## 1596 85
## 1597 51
## 1598 26
## 1599 86
## 1600 53
## 1601 91
## 1602 54
## 1603 55
## 1604 83
## 1605 71
## 1606 89
## 1607 76
## 1608 997
## 1609 31
## 1610 93
## 1611 997
## 1612 96
## 1613 53
## 1614 52
## 1615 71
## 1616 96
## 1617 48
## 1618 89
## 1619 51
## 1620 30
## 1621 50
## 1622 76
## 1623 51
## 1624 12
## 1625 79
## 1626 86
## 1627 66
## 1628 84
## 1629 86
## 1630 80
## 1631 99
## 1632 91
## 1633 62
## 1634 98
## 1635 84
## 1636 80
## 1637 49
## 1638 82
## 1639 30
## 1640 95
## 1641 68
## 1642 93
## 1643 100
## 1644 60
## 1645 60
## 1646 90
## 1647 75
## 1648 85
## 1649 98
## 1650 39
## 1651 53
## 1652 60
## 1653 11
## 1654 50
## 1655 60
## 1656 92
## 1657 50
## 1658 79
## 1659 70
## 1660 70
## 1661 50
## 1662 1
## 1663 78
## 1664 51
## 1665 89
## 1666 59
## 1667 70
## 1668 100
## 1669 28
## 1670 53
## 1671 66
## 1672 81
## 1673 95
## 1674 51
## 1675 50
## 1676 97
## 1677 1
## 1678 51
## 1679 52
## 1680 42
## 1681 75
## 1682 85
## 1683 60
## 1684 100
## 1685 53
## 1686 60
## 1687 85
## 1688 99
## 1689 83
## 1690 93
## 1691 97
## 1692 59
## 1693 97
## 1694 87
## 1695 59
## 1696 48
## 1697 79
## 1698 91
## 1699 60
## 1700 51
## 1701 98
## 1702 78
## 1703 78
## 1704 57
## 1705 50
## 1706 99
## 1707 84
## 1708 27
## 1709 50
## 1710 49
## 1711 74
## 1712 88
## 1713 97
## 1714 92
## 1715 96
## 1716 75
## 1717 64
## 1718 81
## 1719 84
## 1720 83
## 1721 72
## 1722 70
## 1723 50
## 1724 75
## 1725 73
## 1726 80
## 1727 997
## 1728 52
## 1729 59
## 1730 997
## 1731 51
## 1732 89
## 1733 71
## 1734 100
## 1735 98
## 1736 100
## 1737 88
## 1738 99
## 1739 82
## 1740 50
## 1741 7
## 1742 1
## 1743 96
## 1744 64
## 1745 67
## 1746 38
## 1747 51
## 1748 100
## 1749 81
## 1750 50
## 1751 99
## 1752 95
## 1753 48
## 1754 77
## 1755 100
## 1756 90
## 1757 100
## 1758 64
## 1759 50
## 1760 53
## 1761 60
## 1762 11
## 1763 73
## 1764 100
## 1765 82
## 1766 20
## 1767 47
## 1768 25
## 1769 75
## 1770 997
## 1771 90
## 1772 69
## 1773 78
## 1774 25
## 1775 86
## 1776 78
## 1777 100
## 1778 51
## 1779 45
## 1780 29
## 1781 0
## 1782 99
## 1783 50
## 1784 99
## 1785 81
## 1786 85
## 1787 49
## 1788 34
## 1789 997
## 1790 87
## 1791 79
## 1792 75
## 1793 95
## 1794 997
## 1795 997
## 1796 89
## 1797 84
## 1798 50
## 1799 56
## 1800 56
## 1801 78
## 1802 46
## 1803 75
## 1804 79
## 1805 70
## 1806 50
## 1807 98
## 1808 50
## 1809 93
## 1810 98
## 1811 83
## 1812 50
## 1813 50
## 1814 79
## 1815 1
## 1816 100
## 1817 50
## 1818 79
## 1819 51
## 1820 55
## 1821 99
## 1822 95
## 1823 70
## 1824 60
## 1825 61
## 1826 99
## 1827 70
## 1828 100
## 1829 97
## 1830 90
## 1831 36
## 1832 100
## 1833 50
## 1834 82
## 1835 74
## 1836 79
## 1837 51
## 1838 51
## 1839 80
## 1840 50
## 1841 50
## 1842 51
## 1843 71
## 1844 83
## 1845 70
## 1846 0
## 1847 80
## 1848 47
## 1849 51
## 1850 28
## 1851 61
## 1852 19
## 1853 95
## 1854 100
## 1855 91
## 1856 100
## 1857 50
## 1858 75
## 1859 91
## 1860 99
## 1861 100
## 1862 85
## 1863 54
## 1864 73
## 1865 100
## 1866 34
## 1867 76
## 1868 70
## 1869 997
## 1870 51
## 1871 1
## 1872 5
## 1873 50
## 1874 50
## 1875 73
## 1876 4
## 1877 55
## 1878 60
## 1879 997
## 1880 89
## 1881 75
## 1882 79
## 1883 74
## 1884 78
## 1885 41
## 1886 26
## 1887 75
## 1888 91
## 1889 90
## 1890 90
## 1891 80
## 1892 50
## 1893 80
## 1894 77
## 1895 59
## 1896 90
## 1897 58
## 1898 80
## 1899 99
## 1900 80
## 1901 43
## 1902 98
## 1903 74
## 1904 31
## 1905 41
## 1906 56
## 1907 75
## 1908 50
## 1909 98
## 1910 80
## 1911 79
## 1912 50
## 1913 91
## 1914 86
## 1915 100
## 1916 51
## 1917 51
## 1918 55
## 1919 95
## 1920 91
## 1921 44
## 1922 0
## 1923 83
## 1924 50
## 1925 50
## 1926 31
## 1927 42
## 1928 86
## 1929 52
## 1930 50
## 1931 46
## 1932 55
## 1933 50
## 1934 997
## 1935 70
## 1936 71
## 1937 86
## 1938 11
## 1939 83
## 1940 49
## 1941 3
## 1942 100
## 1943 45
## 1944 51
## 1945 81
## 1946 71
## 1947 90
## 1948 30
## 1949 49
## 1950 997
## 1951 50
## 1952 50
## 1953 74
## 1954 2
## 1955 10
## 1956 50
## 1957 92
## 1958 31
## 1959 55
## 1960 99
## 1961 75
## 1962 51
## 1963 40
## 1964 79
## 1965 79
## 1966 5
## 1967 19
## 1968 63
## 1969 99
## 1970 3
## 1971 35
## 1972 60
## 1973 70
## 1974 100
## 1975 50
## 1976 94
## 1977 53
## 1978 28
## 1979 99
## 1980 11
## 1981 997
## 1982 30
## 1983 75
## 1984 65
## 1985 100
## 1986 90
## 1987 90
## 1988 94
## 1989 77
## 1990 33
## 1991 71
## 1992 47
## 1993 0
## 1994 50
## 1995 98
## 1996 69
## 1997 80
## 1998 75
## 1999 91
## 2000 51
## 2001 50
## 2002 100
## 2003 77
## 2004 50
## 2005 998
## 2006 50
## 2007 52
## 2008 1
## 2009 48
## 2010 50
## 2011 50
## 2012 88
## 2013 90
## 2014 50
## 2015 27
## 2016 67
## 2017 86
## 2018 76
## 2019 31
## 2020 11
## 2021 84
## 2022 56
## 2023 54
## 2024 18
## 2025 93
## 2026 50
## 2027 50
## 2028 25
## 2029 48
## 2030 24
## 2031 27
## 2032 90
## 2033 61
## 2034 59
## 2035 80
## 2036 36
## 2037 94
## 2038 79
## 2039 69
## 2040 100
## 2041 61
## 2042 49
## 2043 43
## 2044 76
## 2045 84
## 2046 10
## 2047 75
## 2048 78
## 2049 49
## 2050 95
## 2051 40
## 2052 24
## 2053 51
## 2054 1
## 2055 69
## 2056 3
## 2057 52
## 2058 90
## 2059 78
## 2060 83
## 2061 50
## 2062 50
## 2063 93
## 2064 50
## 2065 75
## 2066 37
## 2067 54
## 2068 43
## 2069 8
## 2070 55
## 2071 4
## 2072 69
## 2073 80
## 2074 55
## 2075 77
## 2076 95
## 2077 45
## 2078 61
## 2079 87
## 2080 96
## 2081 100
## 2082 75
## 2083 80
## 2084 86
## 2085 100
## 2086 50
## 2087 56
## 2088 51
## 2089 87
## 2090 77
## 2091 70
## 2092 75
## 2093 100
## 2094 60
## 2095 81
## 2096 55
## 2097 71
## 2098 6
## 2099 90
## 2100 43
## 2101 98
## 2102 88
## 2103 78
## 2104 14
## 2105 90
## 2106 26
## 2107 50
## 2108 30
## 2109 65
## 2110 100
## 2111 90
## 2112 69
## 2113 39
## 2114 75
## 2115 84
## 2116 88
## 2117 18
## 2118 26
## 2119 88
## 2120 80
## 2121 60
## 2122 50
## 2123 100
## 2124 100
## 2125 78
## 2126 81
## 2127 997
## 2128 100
## 2129 78
## 2130 91
## 2131 99
## 2132 51
## 2133 100
## 2134 95
## 2135 91
## 2136 81
## 2137 50
## 2138 73
## 2139 997
## 2140 49
## 2141 75
## 2142 91
## 2143 81
## 2144 59
## 2145 0
## 2146 70
## 2147 52
## 2148 65
## 2149 89
## 2150 52
## 2151 31
## 2152 50
## 2153 57
## 2154 40
## 2155 37
## 2156 51
## 2157 81
## 2158 100
## 2159 84
## 2160 61
## 2161 99
## 2162 80
## 2163 73
## 2164 49
## 2165 50
## 2166 66
## 2167 100
## 2168 51
## 2169 99
## 2170 6
## 2171 88
## 2172 5
## 2173 30
## 2174 100
## 2175 71
## 2176 61
## 2177 20
## 2178 66
## 2179 62
## 2180 45
## 2181 81
## 2182 71
## 2183 90
## 2184 21
## 2185 997
## 2186 85
## 2187 51
## 2188 100
## 2189 96
## 2190 41
## 2191 64
## 2192 80
## 2193 81
## 2194 31
## 2195 100
## 2196 70
## 2197 67
## 2198 91
## 2199 75
## 2200 100
## 2201 51
## 2202 76
## 2203 46
## 2204 69
## 2205 79
## 2206 91
## 2207 79
## 2208 56
## 2209 78
## 2210 57
## 2211 50
## 2212 91
## 2213 29
## 2214 94
## 2215 15
## 2216 52
## 2217 49
## 2218 997
## 2219 4
## 2220 12
## 2221 1
## 2222 60
## 2223 997
## 2224 58
## 2225 50
## 2226 81
## 2227 66
## 2228 100
## 2229 81
## 2230 58
## 2231 90
## 2232 58
## 2233 100
## 2234 51
## 2235 50
## 2236 51
## 2237 71
## 2238 100
## 2239 56
## 2240 81
## 2241 30
## 2242 997
## 2243 32
## 2244 65
## 2245 50
## 2246 99
## 2247 51
## 2248 99
## 2249 60
## 2250 70
## 2251 41
## 2252 96
## 2253 81
## 2254 63
## 2255 47
## 2256 81
## 2257 70
## 2258 51
## 2259 91
## 2260 72
## 2261 83
## 2262 0
## 2263 45
## 2264 70
## 2265 88
## 2266 98
## 2267 50
## 2268 70
## 2269 32
## 2270 50
## 2271 79
## 2272 51
## 2273 28
## 2274 51
## 2275 59
## 2276 63
## 2277 50
## 2278 53
## 2279 82
## 2280 80
## 2281 86
## 2282 98
## 2283 75
## 2284 80
## 2285 50
## 2286 50
## 2287 63
## 2288 92
## 2289 100
## 2290 98
## 2291 100
## 2292 76
## 2293 12
## 2294 53
## 2295 90
## 2296 90
## 2297 83
## 2298 85
## 2299 50
## 2300 90
## 2301 59
## 2302 50
## 2303 64
## 2304 94
## 2305 50
## 2306 3
## 2307 997
## 2308 95
## 2309 69
## 2310 94
## 2311 99
## 2312 40
## 2313 87
## 2314 79
## 2315 79
## 2316 6
## 2317 19
## 2318 83
## 2319 78
## 2320 52
## 2321 90
## 2322 75
## 2323 50
## 2324 74
## 2325 83
## 2326 76
## 2327 87
## 2328 95
## 2329 100
## 2330 55
## 2331 51
## 2332 69
## 2333 53
## 2334 50
## 2335 75
## 2336 30
## 2337 80
## 2338 75
## 2339 81
## 2340 50
## 2341 31
## 2342 85
## 2343 80
## 2344 99
## 2345 997
## 2346 50
## 2347 53
## 2348 77
## 2349 78
## 2350 81
## 2351 79
## 2352 65
## 2353 99
## 2354 49
## 2355 90
## 2356 98
## 2357 50
## 2358 10
## 2359 81
## 2360 50
## 2361 1
## 2362 91
## 2363 75
## 2364 75
## 2365 94
## 2366 95
## 2367 86
## 2368 63
## 2369 99
## 2370 89
## 2371 1
## 2372 50
## 2373 50
## 2374 3
## 2375 1
## 2376 71
## 2377 61
## 2378 8
## 2379 75
## 2380 48
## 2381 53
## 2382 88
## 2383 66
## 2384 0
## 2385 100
## 2386 88
## 2387 70
## 2388 79
## 2389 73
## 2390 88
## 2391 30
## 2392 82
## 2393 80
## 2394 0
## 2395 41
## 2396 1
## 2397 91
## 2398 90
## 2399 35
## 2400 43
## 2401 95
## 2402 997
## 2403 76
## 2404 90
## 2405 10
## 2406 50
## 2407 98
## 2408 71
## 2409 50
## 2410 4
## 2411 1
## 2412 69
## 2413 70
## 2414 12
## 2415 47
## 2416 98
## 2417 100
## 2418 80
## 2419 99
## 2420 50
## 2421 80
## 2422 95
## 2423 83
## 2424 50
## 2425 70
## 2426 60
## 2427 85
## 2428 84
## 2429 85
## 2430 80
## 2431 100
## 2432 997
## 2433 51
## 2434 50
## 2435 91
## 2436 50
## 2437 79
## 2438 91
## 2439 50
## 2440 78
## 2441 4
## 2442 80
## 2443 95
## 2444 16
## 2445 46
## 2446 99
## 2447 73
## 2448 95
## 2449 1
## 2450 50
## 2451 50
## 2452 28
## 2453 98
## 2454 100
## 2455 100
## 2456 50
## 2457 50
## 2458 75
## 2459 100
## 2460 78
## 2461 50
## 2462 80
## 2463 91
## 2464 88
## 2465 80
## 2466 81
## 2467 76
## 2468 80
## 2469 44
## 2470 70
## 2471 99
## 2472 64
## 2473 16
## 2474 53
## 2475 53
## 2476 83
## 2477 100
## 2478 40
## 2479 92
## 2480 62
## 2481 66
## 2482 60
## 2483 10
## 2484 88
## 2485 52
## 2486 50
## 2487 80
## 2488 86
## 2489 99
## 2490 99
## 2491 56
## 2492 50
## 2493 90
## 2494 56
## 2495 46
## 2496 49
## 2497 100
## 2498 100
## 2499 997
## 2500 100
## 2501 97
## 2502 39
## 2503 59
## 2504 53
## 2505 67
## 2506 997
## 2507 51
## 2508 78
## 2509 52
## 2510 79
## 2511 69
## 2512 100
## 2513 50
## 2514 70
## 2515 90
## 2516 99
## 2517 50
## 2518 61
## 2519 84
## 2520 60
## 2521 100
## 2522 70
## 2523 50
## 2524 997
## 2525 50
## 2526 50
## 2527 50
## 2528 90
## 2529 95
## 2530 51
## 2531 97
## 2532 43
## 2533 51
## 2534 29
## 2535 75
## 2536 100
## 2537 997
## 2538 42
## 2539 63
## 2540 74
## 2541 66
## 2542 91
## 2543 100
## 2544 78
## 2545 98
## 2546 73
## 2547 65
## 2548 44
## 2549 100
## 2550 100
## 2551 100
## 2552 90
## 2553 75
## 2554 60
## 2555 51
## 2556 100
## 2557 78
## 2558 49
## 2559 65
## 2560 100
## 2561 82
## 2562 51
## 2563 90
## 2564 100
## 2565 52
## 2566 60
## 2567 51
## 2568 87
## 2569 51
## 2570 66
## 2571 75
## 2572 1
## 2573 97
## 2574 96
## 2575 48
## 2576 96
## 2577 98
## 2578 98
## 2579 71
## 2580 100
## 2581 68
## 2582 88
## 2583 51
## 2584 997
## 2585 50
## 2586 50
## 2587 0
## 2588 76
## 2589 50
## 2590 50
## 2591 99
## 2592 52
## 2593 23
## 2594 31
## 2595 52
## 2596 997
## 2597 0
## 2598 51
## 2599 98
## 2600 74
## 2601 59
## 2602 96
## 2603 80
## 2604 48
## 2605 52
## 2606 38
## 2607 997
## 2608 100
## 2609 96
## 2610 50
## 2611 76
## 2612 66
## 2613 90
## 2614 78
## 2615 50
## 2616 100
## 2617 8
## 2618 67
## 2619 76
## 2620 85
## 2621 91
## 2622 90
## 2623 77
## 2624 62
## 2625 75
## 2626 90
## 2627 50
## 2628 86
## 2629 100
## 2630 95
## 2631 22
## 2632 81
## 2633 86
## 2634 100
## 2635 78
## 2636 50
## 2637 14
## 2638 80
## 2639 81
## 2640 75
## 2641 73
## 2642 71
## 2643 79
## 2644 50
## 2645 80
## 2646 71
## 2647 78
## 2648 92
## 2649 56
## 2650 63
## 2651 90
## 2652 48
## 2653 78
## 2654 80
## 2655 0
## 2656 50
## 2657 58
## 2658 99
## 2659 51
## 2660 100
## 2661 997
## 2662 90
## 2663 49
## 2664 11
## 2665 50
## 2666 79
## 2667 88
## 2668 44
## 2669 89
## 2670 73
## 2671 85
## 2672 79
## 2673 79
## 2674 75
## 2675 79
## 2676 80
## 2677 73
## 2678 75
## 2679 81
## 2680 21
## 2681 23
## 2682 100
## 2683 80
## 2684 86
## 2685 58
## 2686 28
## 2687 80
## 2688 62
## 2689 23
## 2690 94
## 2691 88
## 2692 51
## 2693 50
## 2694 91
## 2695 50
## 2696 51
## 2697 61
## 2698 46
## 2699 69
## 2700 37
## 2701 99
## 2702 70
## 2703 67
## 2704 100
## 2705 99
## 2706 9
## 2707 80
## 2708 99
## 2709 74
## 2710 56
## 2711 81
## 2712 997
## 2713 76
## 2714 99
## 2715 51
## 2716 53
## 2717 61
## 2718 80
## 2719 60
## 2720 79
## 2721 97
## 2722 50
## 2723 88
## 2724 27
## 2725 50
## 2726 61
## 2727 100
## 2728 43
## 2729 50
## 2730 100
## 2731 70
## 2732 93
## 2733 96
## 2734 99
## 2735 69
## 2736 80
## 2737 75
## 2738 50
## 2739 54
## 2740 88
## 2741 51
## 2742 41
## 2743 51
## 2744 63
## 2745 50
## 2746 51
## 2747 80
## 2748 75
## 2749 26
## 2750 52
## 2751 52
## 2752 51
## 2753 99
## 2754 70
## 2755 99
## 2756 997
## 2757 79
## 2758 50
## 2759 91
## 2760 75
## 2761 49
## 2762 86
## 2763 77
## 2764 77
## 2765 60
## 2766 62
## 2767 67
## 2768 997
## 2769 69
## 2770 98
## 2771 89
## 2772 91
## 2773 100
## 2774 90
## 2775 29
## 2776 47
## 2777 80
## 2778 99
## 2779 100
## 2780 49
## 2781 99
## 2782 76
## 2783 99
## 2784 78
## 2785 80
## 2786 95
## 2787 97
## 2788 50
## 2789 86
## 2790 50
## 2791 80
## 2792 100
## 2793 25
## 2794 72
## 2795 12
## 2796 23
## 2797 41
## 2798 50
## 2799 54
## 2800 92
## 2801 2
## 2802 60
## 2803 50
## 2804 99
## 2805 86
## 2806 51
## 2807 50
## 2808 72
## 2809 6
## 2810 100
## 2811 86
## 2812 82
## 2813 100
## 2814 62
## 2815 70
## 2816 74
## 2817 997
## 2818 50
## 2819 49
## 2820 50
## 2821 69
## 2822 90
## 2823 52
## 2824 31
## 2825 79
## 2826 90
## 2827 77
## 2828 88
## 2829 75
## 2830 84
## 2831 78
## 2832 0
## 2833 44
## 2834 95
## 2835 99
## 2836 44
## 2837 81
## 2838 50
## 2839 1
## 2840 79
## 2841 60
## 2842 97
## 2843 98
## 2844 69
## 2845 99
## 2846 47
## 2847 72
## 2848 71
## 2849 50
## 2850 84
## 2851 50
## 2852 90
## 2853 70
## 2854 66
## 2855 50
## 2856 79
## 2857 59
## 2858 52
## 2859 81
## 2860 95
## 2861 95
## 2862 78
## 2863 20
## 2864 51
## 2865 52
## 2866 50
## 2867 997
## 2868 94
## 2869 62
## 2870 94
## 2871 93
## 2872 72
## 2873 83
## 2874 80
## 2875 80
## 2876 72
## 2877 4
## 2878 80
## 2879 85
## 2880 100
## 2881 71
## 2882 99
## 2883 69
## 2884 90
## 2885 70
## 2886 90
## 2887 89
## 2888 57
## 2889 60
## 2890 62
## 2891 69
## 2892 61
## 2893 29
## 2894 27
## 2895 96
## 2896 62
## 2897 8
## 2898 23
## 2899 83
## 2900 50
## 2901 52
## 2902 90
## 2903 100
## 2904 66
## 2905 80
## 2906 59
## 2907 997
## 2908 7
## 2909 61
## 2910 65
## 2911 50
## 2912 37
## 2913 70
## 2914 64
## 2915 54
## 2916 90
## 2917 20
## 2918 75
## 2919 38
## 2920 66
## 2921 90
## 2922 49
## 2923 76
## 2924 20
## 2925 100
## 2926 78
## 2927 81
## 2928 997
## 2929 51
## 2930 44
## 2931 99
## 2932 11
## 2933 6
## 2934 10
## 2935 97
## 2936 30
## 2937 49
## 2938 98
## 2939 96
## 2940 80
## 2941 73
## 2942 91
## 2943 80
## 2944 50
## 2945 85
## 2946 66
## 2947 90
## 2948 65
## 2949 98
## 2950 88
## 2951 72
## 2952 41
## 2953 6
## 2954 60
## 2955 997
## 2956 97
## 2957 50
## 2958 997
## 2959 85
## 2960 84
## 2961 34
## 2962 80
## 2963 79
## 2964 49
## 2965 94
## 2966 66
## 2967 76
## 2968 997
## 2969 79
## 2970 48
## 2971 29
## 2972 100
## 2973 74
## 2974 80
## 2975 54
## 2976 60
## 2977 46
## 2978 72
## 2979 50
## 2980 87
## 2981 80
## 2982 31
## 2983 47
## 2984 79
## 2985 50
## 2986 8
## 2987 72
## 2988 91
## 2989 23
## 2990 61
## 2991 75
## 2992 99
## 2993 41
## 2994 91
## 2995 68
## 2996 83
## 2997 45
## 2998 72
## 2999 49
## 3000 50
## 3001 81
## 3002 47
## 3003 66
## 3004 53
## 3005 51
## 3006 49
## 3007 100
## 3008 50
## 3009 44
## 3010 51
## 3011 74
## 3012 62
## 3013 90
## 3014 57
## 3015 82
## 3016 83
## 3017 71
## 3018 2
## 3019 61
## 3020 70
## 3021 42
## 3022 7
## 3023 20
## 3024 99
## 3025 43
## 3026 94
## 3027 100
## 3028 25
## 3029 79
## 3030 65
## 3031 81
## 3032 90
## 3033 81
## 3034 56
## 3035 1
## 3036 80
## 3037 997
## 3038 39
## 3039 93
## 3040 78
## 3041 70
## 3042 73
## 3043 80
## 3044 95
## 3045 997
## 3046 79
## 3047 49
## 3048 39
## 3049 50
## 3050 50
## 3051 50
## 3052 4
## 3053 39
## 3054 997
## 3055 76
## 3056 997
## 3057 81
## 3058 78
## 3059 997
## 3060 62
## 3061 100
## 3062 20
## 3063 27
## 3064 50
## 3065 46
## 3066 100
## 3067 91
## 3068 97
## 3069 50
## 3070 0
## 3071 50
## 3072 90
## 3073 70
## 3074 71
## 3075 997
## 3076 80
## 3077 86
## 3078 50
## 3079 100
## 3080 74
## 3081 997
## 3082 90
## 3083 90
## 3084 89
## 3085 18
## 3086 10
## 3087 50
## 3088 72
## 3089 88
## 3090 67
## 3091 99
## 3092 68
## 3093 47
## 3094 26
## 3095 100
## 3096 2
## 3097 52
## 3098 91
## 3099 62
## 3100 52
## 3101 80
## 3102 46
## 3103 33
## 3104 3
## 3105 997
## 3106 76
## 3107 53
## 3108 62
## 3109 95
## 3110 4
## 3111 100
## 3112 100
## 3113 90
## 3114 71
## 3115 997
## 3116 997
## 3117 80
## 3118 997
## 3119 80
## 3120 997
## 3121 52
## 3122 51
## 3123 997
## 3124 90
## 3125 92
## 3126 100
## 3127 50
## 3128 73
## 3129 99
## 3130 79
## 3131 16
## 3132 40
## 3133 44
## 3134 997
## 3135 51
## 3136 73
## 3137 60
## 3138 1
## 3139 6
## 3140 70
## 3141 50
## 3142 60
## 3143 44
## 3144 87
## 3145 11
## 3146 83
## 3147 75
## 3148 100
## 3149 98
## 3150 100
## 3151 66
## 3152 70
## 3153 43
## 3154 76
## 3155 78
## 3156 74
## 3157 91
## 3158 100
## 3159 81
## 3160 81
## 3161 100
## 3162 74
## 3163 93
## 3164 99
## 3165 50
## 3166 70
## 3167 75
## 3168 100
## 3169 77
## 3170 90
## 3171 37
## 3172 55
## 3173 99
## 3174 86
## 3175 60
## 3176 99
## 3177 35
## 3178 91
## 3179 97
## 3180 50
## 3181 40
## 3182 77
## 3183 98
## 3184 75
## 3185 99
## 3186 80
## 3187 75
## 3188 40
## 3189 99
## 3190 81
## 3191 96
## 3192 100
## 3193 100
## 3194 59
## 3195 85
## 3196 51
## 3197 99
## 3198 997
## 3199 100
## 3200 70
## 3201 80
## 3202 100
## 3203 66
## 3204 57
## 3205 997
## 3206 90
## 3207 100
## 3208 61
## 3209 90
## 3210 81
## 3211 97
## 3212 84
## 3213 88
## 3214 51
## 3215 53
## 3216 17
## 3217 95
## 3218 79
## 3219 10
## 3220 70
## 3221 85
## 3222 100
## 3223 81
## 3224 90
## 3225 90
## 3226 99
## 3227 100
## 3228 84
## 3229 61
## 3230 78
## 3231 80
## 3232 51
## 3233 98
## 3234 80
## 3235 82
## 3236 50
## 3237 81
## 3238 50
## 3239 99
## 3240 53
## 3241 100
## 3242 24
## 3243 85
## 3244 100
## 3245 81
## 3246 60
## 3247 94
## 3248 91
## 3249 100
## 3250 70
## 3251 86
## 3252 50
## 3253 73
## 3254 10
## 3255 50
## 3256 50
## 3257 51
## 3258 77
## 3259 75
## 3260 80
## 3261 50
## 3262 89
## 3263 99
## 3264 75
## 3265 74
## 3266 78
## 3267 51
## 3268 99
## 3269 53
## 3270 100
## 3271 50
## 3272 78
## 3273 99
## 3274 98
## 3275 96
## 3276 38
## 3277 25
## 3278 81
## 3279 997
## 3280 50
## 3281 98
## 3282 50
## 3283 90
## 3284 12
## 3285 7
## 3286 78
## 3287 75
## 3288 80
## 3289 96
## 3290 50
## 3291 53
## 3292 100
## 3293 997
## 3294 76
## 3295 997
## 3296 41
## 3297 99
## 3298 77
## 3299 53
## 3300 55
## 3301 78
## 3302 89
## 3303 64
## 3304 76
## 3305 49
## 3306 69
## 3307 61
## 3308 81
## 3309 22
## 3310 75
## 3311 74
## 3312 60
## 3313 84
## 3314 73
## 3315 70
## 3316 49
## 3317 83
## 3318 51
## 3319 26
## 3320 50
## 3321 10
## 3322 5
## 3323 99
## 3324 80
## 3325 50
## 3326 50
## 3327 75
## 3328 50
## 3329 49
## 3330 94
## 3331 51
## 3332 50
## 3333 1
## 3334 24
## 3335 51
## 3336 100
## 3337 76
## 3338 96
## 3339 997
## 3340 76
## 3341 61
## 3342 89
## 3343 49
## 3344 2
## 3345 100
## 3346 100
## 3347 41
## 3348 50
## 3349 60
## 3350 74
## 3351 997
## 3352 99
## 3353 82
## 3354 67
## 3355 100
## 3356 50
## 3357 51
## 3358 58
## 3359 14
## 3360 50
## 3361 68
## 3362 10
## 3363 81
## 3364 59
## 3365 99
## 3366 70
## 3367 80
## 3368 100
## 3369 70
## 3370 61
## 3371 56
## 3372 50
## 3373 50
## 3374 80
## 3375 93
## 3376 997
## 3377 51
## 3378 100
## 3379 2
## 3380 83
## 3381 100
## 3382 51
## 3383 60
## 3384 78
## 3385 66
## 3386 99
## 3387 100
## 3388 29
## 3389 51
## 3390 50
## 3391 56
## 3392 50
## 3393 100
## 3394 50
## 3395 48
## 3396 43
## 3397 80
## 3398 50
## 3399 60
## 3400 95
## 3401 58
## 3402 75
## 3403 50
## 3404 58
## 3405 75
## 3406 88
## 3407 76
## 3408 82
## 3409 65
## 3410 50
## 3411 5
## 3412 100
## 3413 92
## 3414 91
## 3415 99
## 3416 52
## 3417 99
## 3418 59
## 3419 51
## 3420 997
## 3421 94
## 3422 88
## 3423 100
## 3424 51
## 3425 1
## 3426 75
## 3427 92
## 3428 64
## 3429 75
## 3430 76
## 3431 73
## 3432 50
## 3433 50
## 3434 31
## 3435 71
## 3436 87
## 3437 47
## 3438 74
## 3439 50
## 3440 60
## 3441 78
## 3442 70
## 3443 50
## 3444 29
## 3445 74
## 3446 83
## 3447 52
## 3448 80
## 3449 38
## 3450 95
## 3451 19
## 3452 95
## 3453 30
## 3454 56
## 3455 100
## 3456 47
## 3457 71
## 3458 75
## 3459 52
## 3460 59
## 3461 75
## 3462 94
## 3463 100
## 3464 49
## 3465 68
## 3466 997
## 3467 62
## 3468 63
## 3469 80
## 3470 69
## 3471 69
## 3472 82
## 3473 49
## 3474 90
## 3475 11
## 3476 50
## 3477 80
## 3478 100
## 3479 84
## 3480 81
## 3481 100
## 3482 80
## 3483 51
## 3484 95
## 3485 40
## 3486 95
## 3487 70
## 3488 90
## 3489 75
## 3490 50
## 3491 26
## 3492 51
## 3493 100
## 3494 97
## 3495 96
## 3496 79
## 3497 78
## 3498 91
## 3499 97
## 3500 81
## 3501 49
## 3502 90
## 3503 50
## 3504 10
## 3505 93
## 3506 99
## 3507 100
## 3508 78
## 3509 90
## 3510 62
## 3511 83
## 3512 59
## 3513 95
## 3514 4
## 3515 51
## 3516 50
## 3517 71
## 3518 28
## 3519 47
## 3520 50
## 3521 54
## 3522 76
## 3523 100
## 3524 67
## 3525 51
## 3526 80
## 3527 90
## 3528 88
## 3529 91
## 3530 997
## 3531 51
## 3532 40
## 3533 37
## 3534 89
## 3535 79
## 3536 50
## 3537 5
## 3538 35
## 3539 50
## 3540 45
## 3541 76
## 3542 54
## 3543 89
## 3544 80
## 3545 60
## 3546 51
## 3547 100
## 3548 70
## 3549 50
## 3550 73
## 3551 42
## 3552 78
## 3553 47
## 3554 70
## 3555 47
## 3556 90
## 3557 56
## 3558 81
## 3559 75
## 3560 50
## 3561 67
## 3562 83
## 3563 97
## 3564 1
## 3565 40
## 3566 50
## 3567 31
## 3568 48
## 3569 39
## 3570 91
## 3571 59
## 3572 11
## 3573 99
## 3574 100
## 3575 56
## 3576 50
## 3577 98
## 3578 50
## 3579 997
## 3580 50
## 3581 8
## 3582 99
## 3583 99
## 3584 51
## 3585 92
## 3586 92
## 3587 98
## 3588 99
## 3589 100
## 3590 75
## 3591 50
## 3592 66
## 3593 997
## 3594 90
## 3595 75
## 3596 50
## 3597 56
## 3598 3
## 3599 75
## 3600 997
## 3601 70
## 3602 100
## 3603 50
## 3604 50
## 3605 7
## 3606 100
## 3607 45
## 3608 64
## 3609 82
## 3610 50
## 3611 84
## 3612 50
## 3613 47
## 3614 87
## 3615 60
## 3616 91
## 3617 81
## 3618 72
## 3619 93
## 3620 90
## 3621 49
## 3622 100
## 3623 91
## 3624 85
## 3625 80
## 3626 100
## 3627 65
## 3628 75
## 3629 71
## 3630 4
## 3631 92
## 3632 3
## 3633 29
## 3634 100
## 3635 86
## 3636 61
## 3637 45
## 3638 69
## 3639 96
## 3640 50
## 3641 997
## 3642 96
## 3643 80
## 3644 75
## 3645 88
## 3646 46
## 3647 50
## 3648 51
## 3649 99
## 3650 2
## 3651 51
## 3652 48
## 3653 80
## 3654 100
## 3655 75
## 3656 43
## 3657 93
## 3658 90
## 3659 16
## 3660 80
## 3661 80
## 3662 99
## 3663 90
## 3664 50
## 3665 85
## 3666 77
## 3667 80
## 3668 100
## 3669 84
## 3670 7
## 3671 60
## 3672 16
## 3673 86
## 3674 84
## 3675 86
## 3676 51
## 3677 78
## 3678 66
## 3679 99
## 3680 97
## 3681 100
## 3682 93
## 3683 92
## 3684 90
## 3685 51
## 3686 997
## 3687 997
## 3688 84
## 3689 41
## 3690 59
## 3691 31
## 3692 80
## 3693 60
## 3694 90
## 3695 52
## 3696 100
## 3697 87
## 3698 100
## 3699 71
## 3700 70
## 3701 50
## 3702 100
## 3703 51
## 3704 59
## 3705 74
## 3706 91
## 3707 81
## 3708 88
## 3709 100
## 3710 11
## 3711 31
## 3712 50
## 3713 47
## 3714 90
## 3715 99
## 3716 61
## 3717 62
## 3718 79
## 3719 2
## 3720 81
## 3721 40
## 3722 76
## 3723 69
## 3724 100
## 3725 50
## 3726 80
## 3727 81
## 3728 100
## 3729 7
## 3730 50
## 3731 100
## 3732 95
## 3733 50
## 3734 92
## 3735 100
## 3736 100
## 3737 67
## 3738 80
## 3739 70
## 3740 100
## 3741 65
## 3742 50
## 3743 71
## 3744 100
## 3745 78
## 3746 48
## 3747 2
## 3748 53
## 3749 51
## 3750 997
## 3751 90
## 3752 50
## 3753 100
## 3754 93
## 3755 997
## 3756 97
## 3757 997
## 3758 47
## 3759 25
## 3760 48
## 3761 997
## 3762 88
## 3763 997
## 3764 55
## 3765 85
## 3766 51
## 3767 20
## 3768 90
## 3769 50
## 3770 80
## 3771 98
## 3772 100
## 3773 60
## 3774 100
## 3775 91
## 3776 55
## 3777 51
## 3778 80
## 3779 77
## 3780 91
## 3781 78
## 3782 78
## 3783 81
## 3784 90
## 3785 53
## 3786 64
## 3787 100
## 3788 13
## 3789 50
## 3790 48
## 3791 34
## 3792 100
## 3793 100
## 3794 83
## 3795 87
## 3796 90
## 3797 76
## 3798 68
## 3799 100
## 3800 78
## 3801 87
## 3802 70
## 3803 997
## 3804 76
## 3805 75
## 3806 74
## 3807 70
## 3808 40
## 3809 98
## 3810 20
## 3811 100
## 3812 25
## 3813 76
## 3814 80
## 3815 70
## 3816 60
## 3817 7
## 3818 65
## 3819 18
## 3820 100
## 3821 73
## 3822 30
## 3823 73
## 3824 100
## 3825 63
## 3826 81
## 3827 75
## 3828 99
## 3829 49
## 3830 997
## 3831 89
## 3832 62
## 3833 25
## 3834 52
## 3835 40
## 3836 90
## 3837 100
## 3838 77
## 3839 97
## 3840 22
## 3841 55
## 3842 58
## 3843 85
## 3844 54
## 3845 74
## 3846 69
## 3847 30
## 3848 28
## 3849 50
## 3850 99
## 3851 997
## 3852 70
## 3853 14
## 3854 76
## 3855 91
## 3856 54
## 3857 4
## 3858 100
## 3859 99
## 3860 98
## 3861 98
## 3862 90
## 3863 96
## 3864 62
## 3865 81
## 3866 99
## 3867 98
## 3868 95
## 3869 82
## 3870 94
## 3871 41
## 3872 46
## 3873 14
## 3874 20
## 3875 28
## 3876 48
## 3877 997
## 3878 54
## 3879 90
## 3880 69
## 3881 74
## 3882 99
## 3883 91
## 3884 75
## 3885 50
## 3886 31
## 3887 46
## 3888 50
## 3889 52
## 3890 75
## 3891 48
## 3892 48
## 3893 50
## 3894 61
## 3895 80
## 3896 79
## 3897 98
## 3898 60
## 3899 50
## 3900 77
## 3901 76
## 3902 56
## 3903 100
## 3904 58
## 3905 84
## 3906 58
## 3907 61
## 3908 38
## 3909 50
## 3910 71
## 3911 54
## 3912 49
## 3913 78
## 3914 90
## 3915 75
## 3916 29
## 3917 50
## 3918 100
## 3919 79
## 3920 50
## 3921 49
## 3922 6
## 3923 82
## 3924 47
## 3925 59
## 3926 71
## 3927 100
## 3928 100
## 3929 70
## 3930 79
## 3931 80
## 3932 12
## 3933 100
## 3934 50
## 3935 70
## 3936 97
## 3937 68
## 3938 13
## 3939 997
## 3940 5
## 3941 67
## 3942 997
## 3943 58
## 3944 29
## 3945 75
## 3946 77
## 3947 51
## 3948 52
## 3949 50
## 3950 100
## 3951 45
## 3952 50
## 3953 59
## 3954 100
## 3955 50
## 3956 51
## 3957 73
## 3958 59
## 3959 75
## 3960 78
## 3961 99
## 3962 997
## 3963 80
## 3964 65
## 3965 89
## 3966 50
## 3967 997
## 3968 95
## 3969 95
## 3970 47
## 3971 97
## 3972 76
## 3973 76
## 3974 50
## 3975 65
## 3976 80
## 3977 5
## 3978 94
## 3979 65
## 3980 90
## 3981 88
## 3982 49
## 3983 91
## 3984 91
## 3985 50
## 3986 68
## 3987 99
## 3988 84
## 3989 50
## 3990 100
## 3991 85
## 3992 100
## 3993 997
## 3994 997
## 3995 50
## 3996 94
## 3997 94
## 3998 90
## 3999 69
## 4000 99
## 4001 36
## 4002 77
## 4003 80
## 4004 96
## 4005 64
## 4006 50
## 4007 50
## 4008 79
## 4009 81
## 4010 997
## 4011 72
## 4012 0
## 4013 56
## 4014 5
## 4015 70
## 4016 997
## 4017 79
## 4018 0
## 4019 80
## 4020 100
## 4021 50
## 4022 47
## 4023 997
## 4024 50
## 4025 38
## 4026 63
## 4027 99
## 4028 100
## 4029 98
## 4030 77
## 4031 85
## 4032 49
## 4033 95
## 4034 997
## 4035 79
## 4036 79
## 4037 74
## 4038 55
## 4039 73
## 4040 48
## 4041 75
## 4042 90
## 4043 4
## 4044 60
## 4045 91
## 4046 68
## 4047 86
## 4048 997
## 4049 50
## 4050 96
## 4051 81
## 4052 90
## 4053 77
## 4054 98
## 4055 99
## 4056 81
## 4057 75
## 4058 38
## 4059 20
## 4060 9
## 4061 98
## 4062 85
## 4063 72
## 4064 78
## 4065 32
## 4066 90
## 4067 70
## 4068 60
## 4069 52
## 4070 82
## 4071 2
## 4072 100
## 4073 82
## 4074 90
## 4075 96
## 4076 23
## 4077 997
## 4078 50
## 4079 50
## 4080 51
## 4081 23
## 4082 100
## 4083 47
## 4084 51
## 4085 0
## 4086 52
## 4087 79
## 4088 83
## 4089 89
## 4090 97
## 4091 99
## 4092 51
## 4093 997
## 4094 98
## 4095 75
## 4096 76
## 4097 0
## 4098 997
## 4099 58
## 4100 50
## 4101 50
## 4102 50
## 4103 50
## 4104 58
## 4105 80
## 4106 83
## 4107 67
## 4108 997
## 4109 54
## 4110 65
## 4111 51
## 4112 56
## 4113 71
## 4114 25
## 4115 96
## 4116 95
## 4117 93
## 4118 50
## 4119 68
## 4120 56
## 4121 50
## 4122 46
## 4123 90
## 4124 100
## 4125 74
## 4126 89
## 4127 50
## 4128 85
## 4129 83
## 4130 54
## 4131 17
## 4132 47
## 4133 2
## 4134 51
## 4135 997
## 4136 100
## 4137 997
## 4138 100
## 4139 40
## 4140 62
## 4141 50
## 4142 79
## 4143 997
## 4144 20
## 4145 42
## 4146 39
## 4147 60
## 4148 10
## 4149 48
## 4150 82
## 4151 57
## 4152 97
## 4153 81
## 4154 88
## 4155 56
## 4156 82
## 4157 40
## 4158 21
## 4159 75
## 4160 33
## 4161 43
## 4162 997
## 4163 100
## 4164 100
## 4165 54
## 4166 997
## 4167 74
## 4168 97
## 4169 99
## 4170 100
## 4171 997
## 4172 22
## 4173 30
## 4174 99
## 4175 96
## 4176 97
## 4177 80
## 4178 46
## 4179 50
## 4180 96
## 4181 53
## 4182 50
## 4183 997
## 4184 95
## 4185 50
## 4186 77
## 4187 53
## 4188 81
## 4189 70
## 4190 100
## 4191 63
## 4192 71
## 4193 74
## 4194 998
## 4195 94
## 4196 100
## 4197 93
## 4198 79
## 4199 99
## 4200 61
## 4201 99
## 4202 68
## 4203 89
## 4204 28
## 4205 80
## 4206 76
## 4207 89
## 4208 997
## 4209 997
## 4210 997
## 4211 90
## 4212 40
## 4213 99
## 4214 100
## 4215 75
## 4216 50
## 4217 3
## 4218 39
## 4219 82
## 4220 50
## 4221 75
## 4222 87
## 4223 90
## 4224 82
## 4225 91
## 4226 90
## 4227 70
## 4228 71
## 4229 97
## 4230 47
## 4231 15
## 4232 93
## 4233 61
## 4234 64
## 4235 51
## 4236 61
## 4237 98
## 4238 99
## 4239 61
## 4240 997
## 4241 60
## 4242 86
## 4243 52
## 4244 55
## 4245 31
## 4246 75
## 4247 66
## 4248 73
## 4249 91
## 4250 76
## 4251 43
## 4252 61
## 4253 48
## 4254 86
## 4255 17
## 4256 51
## 4257 99
## 4258 75
## 4259 19
## 4260 46
## 4261 75
## 4262 69
## 4263 1
## 4264 66
## 4265 62
## 4266 997
## 4267 77
## 4268 80
## 4269 56
## 4270 81
## 4271 92
## 4272 75
## 4273 97
## 4274 50
## 4275 90
## 4276 52
## 4277 94
## 4278 97
## 4279 997
## 4280 80
## 4281 0
## 4282 90
## 4283 100
## 4284 100
## 4285 50
## 4286 79
## 4287 50
## 4288 33
## 4289 74
## 4290 50
## 4291 100
## 4292 50
## 4293 100
## 4294 75
## 4295 100
## 4296 9
## 4297 64
## 4298 40
## 4299 55
## 4300 91
## 4301 27
## 4302 78
## 4303 71
## 4304 73
## 4305 100
## 4306 59
## 4307 6
## 4308 97
## 4309 80
## 4310 50
## 4311 69
## 4312 3
## 4313 100
## 4314 50
## 4315 91
## 4316 60
## 4317 997
## 4318 87
## 4319 95
## 4320 997
## 4321 50
## 4322 53
## 4323 100
## 4324 51
## 4325 21
## 4326 80
## 4327 50
## 4328 50
## 4329 42
## 4330 50
## 4331 99
## 4332 46
## 4333 90
## 4334 54
## 4335 66
## 4336 41
## 4337 72
## 4338 100
## 4339 51
## 4340 50
## 4341 47
## 4342 96
## 4343 68
## 4344 60
## 4345 2
## 4346 60
## 4347 100
## 4348 997
## 4349 100
## 4350 47
## 4351 50
## 4352 49
## 4353 71
## 4354 81
## 4355 52
## 4356 50
## 4357 48
## 4358 79
## 4359 100
## 4360 77
## 4361 10
## 4362 100
## 4363 25
## 4364 100
## 4365 997
## 4366 997
## 4367 100
## 4368 91
## 4369 80
## 4370 62
## 4371 100
## 4372 80
## 4373 51
## 4374 99
## 4375 95
## 4376 66
## 4377 88
## 4378 100
## 4379 67
## 4380 100
## 4381 90
## 4382 51
## 4383 100
## 4384 997
## 4385 93
## 4386 997
## 4387 100
## 4388 27
## 4389 66
## 4390 83
## 4391 100
## 4392 85
## 4393 53
## 4394 100
## 4395 100
## 4396 99
## 4397 100
## 4398 61
## 4399 1
## 4400 83
## 4401 100
## 4402 77
## 4403 82
## 4404 100
## 4405 51
## 4406 997
## 4407 12
## 4408 61
## 4409 77
## 4410 98
## 4411 51
## 4412 94
## 4413 100
## 4414 92
## 4415 100
## 4416 100
## 4417 51
## 4418 88
## 4419 68
## 4420 80
## 4421 33
## 4422 96
## 4423 99
## 4424 67
## 4425 42
## 4426 100
## 4427 52
## 4428 96
## 4429 85
## 4430 11
## 4431 77
## 4432 75
## 4433 49
## 4434 68
## 4435 80
## 4436 67
## 4437 100
## 4438 49
## 4439 100
## 4440 99
## 4441 75
## 4442 55
## 4443 100
## 4444 99
## 4445 997
## 4446 61
## 4447 997
## 4448 51
## 4449 95
## 4450 47
## 4451 100
## 4452 51
## 4453 997
## 4454 51
## 4455 99
## 4456 5
## 4457 99
## 4458 50
## 4459 99
## 4460 75
## 4461 75
## 4462 97
## 4463 50
## 4464 80
## 4465 5
## 4466 75
## 4467 86
## 4468 997
## 4469 99
## 4470 55
## 4471 96
## 4472 63
## 4473 48
## 4474 48
## 4475 82
## 4476 997
## 4477 997
## 4478 43
## 4479 73
## 4480 99
## 4481 81
## 4482 100
## 4483 100
## 4484 74
## 4485 61
## 4486 50
## 4487 62
## 4488 997
## 4489 9
## 4490 58
## 4491 50
## 4492 997
## 4493 95
## 4494 58
## 4495 98
## 4496 997
## 4497 100
## 4498 100
## 4499 100
## 4500 8
## 4501 997
## 4502 90
## 4503 71
## 4504 100
## 4505 39
## 4506 2
## 4507 100
## 4508 11
## 4509 91
## 4510 96
## 4511 997
## 4512 51
## 4513 50
## 4514 26
## 4515 28
## 4516 55
## 4517 1
## 4518 92
## 4519 58
## 4520 81
## 4521 89
## 4522 98
## 4523 78
## 4524 42
## 4525 14
## 4526 50
## 4527 41
## 4528 100
## 4529 75
## 4530 50
## 4531 50
## 4532 45
## 4533 30
## 4534 50
## 4535 96
## 4536 997
## 4537 997
## 4538 100
## 4539 3
## 4540 92
## 4541 997
## 4542 49
## 4543 51
## 4544 78
## 4545 997
## 4546 79
## 4547 99
## 4548 997
## 4549 49
## 4550 84
## 4551 30
## 4552 997
## 4553 997
## 4554 49
## 4555 72
## 4556 56
## 4557 90
## 4558 57
## 4559 76
## 4560 24
## 4561 71
## 4562 20
## 4563 99
## 4564 49
## 4565 100
## 4566 49
## 4567 45
## 4568 46
## 4569 64
## 4570 74
## 4571 55
## 4572 32
## 4573 84
## 4574 56
## 4575 80
## 4576 77
## 4577 997
## 4578 997
## 4579 68
## 4580 52
## 4581 91
## 4582 76
## 4583 50
## 4584 51
## 4585 8
## 4586 75
## 4587 51
## 4588 100
## 4589 44
## 4590 91
## 4591 96
## 4592 997
## 4593 66
## 4594 56
## 4595 92
## 4596 51
## 4597 25
## 4598 95
## 4599 85
## 4600 997
## 4601 61
## 4602 50
## 4603 100
## 4604 99
## 4605 54
## 4606 100
## 4607 997
## 4608 6
## 4609 56
## 4610 56
## 4611 74
## 4612 50
## 4613 53
## 4614 997
## 4615 83
## 4616 83
## 4617 50
## 4618 99
## 4619 70
## 4620 53
## 4621 81
## 4622 50
## 4623 997
## 4624 98
## 4625 100
## 4626 81
## 4627 50
## 4628 48
## 4629 47
## 4630 90
## 4631 100
## 4632 99
## 4633 100
## 4634 55
## 4635 28
## 4636 77
## 4637 94
## 4638 74
## 4639 90
## 4640 99
## 4641 90
## 4642 46
## 4643 51
## 4644 88
## 4645 70
## 4646 1
## 4647 2
## 4648 73
## 4649 100
## 4650 56
## 4651 71
## 4652 50
## 4653 74
## 4654 50
## 4655 100
## 4656 75
## 4657 70
## 4658 67
## 4659 997
## 4660 100
## 4661 37
## 4662 100
## 4663 22
## 4664 59
## 4665 10
## 4666 80
## 4667 50
## 4668 76
## 4669 65
## 4670 66
## 4671 83
## 4672 997
## 4673 80
## 4674 75
## 4675 50
## 4676 64
## 4677 98
## 4678 75
## 4679 21
## 4680 92
## 4681 997
## 4682 100
## 4683 100
## 4684 1
## 4685 76
## 4686 49
## 4687 75
## 4688 35
## 4689 50
## 4690 90
## 4691 50
## 4692 50
## 4693 50
## 4694 75
## 4695 91
## 4696 30
## 4697 4
## 4698 83
## 4699 100
## 4700 75
## 4701 55
## 4702 11
## 4703 50
## 4704 95
## 4705 97
## 4706 50
## 4707 71
## 4708 92
## 4709 90
## 4710 0
## 4711 31
## 4712 85
## 4713 100
## 4714 83
## 4715 75
## 4716 71
## 4717 88
## 4718 100
## 4719 70
## 4720 68
## 4721 47
## 4722 19
## 4723 50
## 4724 48
## 4725 98
## 4726 100
## 4727 90
## 4728 80
## 4729 99
## 4730 40
## 4731 75
## 4732 94
## 4733 1
## 4734 84
## 4735 42
## 4736 81
## 4737 61
## 4738 90
## 4739 68
## 4740 54
## 4741 80
## 4742 79
## 4743 39
## 4744 61
## 4745 71
## 4746 97
## 4747 67
## 4748 31
## 4749 96
## 4750 50
## 4751 89
## 4752 50
## 4753 84
## 4754 48
## 4755 71
## 4756 97
## 4757 30
## 4758 89
## 4759 99
## 4760 50
## 4761 45
## 4762 62
## 4763 71
## 4764 80
## 4765 98
## 4766 89
## 4767 98
## 4768 0
## 4769 100
## 4770 99
## 4771 997
## 4772 70
## 4773 46
## 4774 60
## 4775 50
## 4776 50
## 4777 3
## 4778 99
## 4779 65
## 4780 100
## 4781 100
## 4782 100
## 4783 54
## 4784 48
## 4785 24
## 4786 99
## 4787 51
## 4788 89
## 4789 100
## 4790 80
## 4791 48
## 4792 53
## 4793 93
## 4794 66
## 4795 1
## 4796 80
## 4797 41
## 4798 997
## 4799 71
## 4800 49
## 4801 75
## 4802 42
## 4803 997
## 4804 52
## 4805 50
## 4806 58
## 4807 75
## 4808 77
## 4809 98
## 4810 47
## 4811 76
## 4812 997
## 4813 64
## 4814 75
## 4815 69
## 4816 100
## 4817 11
## 4818 90
## 4819 99
## 4820 88
## 4821 51
## 4822 77
## 4823 97
## 4824 997
## 4825 80
## 4826 81
## 4827 49
## 4828 73
## 4829 48
## 4830 997
## 4831 51
## 4832 2
## 4833 54
## 4834 55
## 4835 19
## 4836 54
## 4837 51
## 4838 99
## 4839 51
## 4840 100
## 4841 29
## 4842 997
## 4843 15
## 4844 74
## 4845 99
## 4846 51
## 4847 87
## 4848 79
## 4849 99
## 4850 997
## 4851 30
## 4852 100
## 4853 51
## 4854 83
## 4855 84
## 4856 75
## 4857 51
## 4858 9
## 4859 66
## 4860 75
## 4861 51
## 4862 48
## 4863 52
## 4864 83
## 4865 55
## 4866 95
## 4867 77
## 4868 48
## 4869 57
## 4870 74
## 4871 71
## 4872 93
## 4873 47
## 4874 997
## 4875 72
## 4876 81
## 4877 50
## 4878 93
## 4879 48
## 4880 50
## 4881 70
## 4882 58
## 4883 71
## 4884 100
## 4885 90
## 4886 52
## 4887 100
## 4888 49
## 4889 90
## 4890 76
## 4891 100
## 4892 79
## 4893 26
## 4894 24
## 4895 76
## 4896 100
## 4897 78
## 4898 47
## 4899 47
## 4900 60
## 4901 54
## 4902 51
## 4903 25
## 4904 28
## 4905 100
## 4906 100
## 4907 26
## 4908 28
## 4909 30
## 4910 79
## 4911 100
## 4912 84
## 4913 25
## 4914 100
## 4915 997
## 4916 81
## 4917 90
## 4918 90
## 4919 0
## 4920 66
## 4921 100
## 4922 50
## 4923 51
## 4924 91
## 4925 45
## 4926 96
## 4927 997
## 4928 83
## 4929 86
## 4930 96
## 4931 51
## 4932 75
## 4933 92
## 4934 100
## 4935 0
## 4936 100
## 4937 56
## 4938 87
## 4939 80
## 4940 99
## 4941 70
## 4942 49
## 4943 84
## 4944 49
## 4945 997
## 4946 83
## 4947 92
## 4948 91
## 4949 92
## 4950 92
## 4951 100
## 4952 52
## 4953 51
## 4954 45
## 4955 100
## 4956 997
## 4957 50
## 4958 51
## 4959 97
## 4960 997
## 4961 35
## 4962 48
## 4963 75
## 4964 85
## 4965 98
## 4966 74
## 4967 997
## 4968 78
## 4969 2
## 4970 100
## 4971 71
## 4972 57
## 4973 98
## 4974 76
## 4975 50
## 4976 99
## 4977 99
## 4978 85
## 4979 90
## 4980 73
## 4981 33
## 4982 51
## 4983 15
## 4984 99
## 4985 93
## 4986 50
## 4987 3
## 4988 55
## 4989 86
## 4990 96
## 4991 92
## 4992 44
## 4993 48
## 4994 81
## 4995 79
## 4996 75
## 4997 100
## 4998 997
## 4999 52
## 5000 97
## 5001 56
## 5002 38
## 5003 3
## 5004 100
## 5005 100
## 5006 79
## 5007 32
## 5008 997
## 5009 80
## 5010 99
## 5011 90
## 5012 56
## 5013 997
## 5014 22
## 5015 73
## 5016 100
## 5017 997
## 5018 100
## 5019 77
## 5020 100
## 5021 90
## 5022 92
## 5023 26
## 5024 52
## 5025 50
## 5026 90
## 5027 997
## 5028 89
## 5029 50
## 5030 76
## 5031 50
## 5032 49
## 5033 80
## 5034 45
## 5035 997
## 5036 95
## 5037 0
## 5038 83
## 5039 88
## 5040 91
## 5041 99
## 5042 77
## 5043 997
## 5044 1
## 5045 997
## 5046 80
## 5047 50
## 5048 77
## 5049 81
## 5050 81
## 5051 100
## 5052 68
## 5053 97
## 5054 68
## 5055 50
## 5056 99
## 5057 997
## 5058 50
## 5059 2
## 5060 51
## 5061 100
## 5062 100
## 5063 99
## 5064 23
## 5065 10
## 5066 997
## 5067 100
## 5068 78
## 5069 100
## 5070 99
## 5071 50
## 5072 97
## 5073 99
## 5074 55
## 5075 17
## 5076 67
## 5077 98
## 5078 73
## 5079 72
## 5080 7
## 5081 50
## 5082 92
## 5083 79
## 5084 997
## 5085 46
## 5086 44
## 5087 50
## 5088 100
## 5089 30
## 5090 99
## 5091 83
## 5092 50
## 5093 63
## 5094 63
## 5095 93
## 5096 50
## 5097 38
## 5098 59
## 5099 50
## 5100 66
## 5101 94
## 5102 100
## 5103 90
## 5104 50
## 5105 58
## 5106 91
## 5107 12
## 5108 80
## 5109 75
## 5110 42
## 5111 96
## 5112 72
## 5113 82
## 5114 43
## 5115 50
## 5116 80
## 5117 50
## 5118 100
## 5119 81
## 5120 100
## 5121 60
## 5122 15
## 5123 15
## 5124 81
## 5125 997
## 5126 997
## 5127 100
## 5128 997
## 5129 10
## 5130 100
## 5131 94
## 5132 66
## 5133 62
## 5134 100
## 5135 100
## 5136 997
## 5137 997
## 5138 96
## 5139 50
## 5140 51
## 5141 78
## 5142 44
## 5143 77
## 5144 96
## 5145 63
## 5146 85
## 5147 97
## 5148 77
## 5149 30
## 5150 997
## 5151 60
## 5152 56
## 5153 74
## 5154 100
## 5155 50
## 5156 64
## 5157 50
## 5158 46
## 5159 0
## 5160 6
## 5161 100
## 5162 70
## 5163 99
## 5164 59
## 5165 50
## 5166 75
## 5167 80
## 5168 50
## 5169 96
## 5170 66
## 5171 100
## 5172 50
## 5173 50
## 5174 100
## 5175 39
## 5176 27
## 5177 997
## 5178 50
## 5179 51
## 5180 99
## 5181 73
## 5182 99
## 5183 92
## 5184 997
## 5185 70
## 5186 50
## 5187 997
## 5188 98
## 5189 3
## 5190 50
## 5191 99
## 5192 50
## 5193 78
## 5194 47
## 5195 100
## 5196 50
## 5197 50
## 5198 64
## 5199 71
## 5200 42
## 5201 59
## 5202 0
## 5203 86
## 5204 50
## 5205 9
## 5206 997
## 5207 997
## 5208 40
## 5209 99
## 5210 100
## 5211 60
## 5212 31
## 5213 60
## 5214 99
## 5215 997
## 5216 997
## 5217 84
## 5218 100
## 5219 64
## 5220 3
## 5221 35
## 5222 95
## 5223 50
## 5224 50
## 5225 55
## 5226 100
## 5227 997
## 5228 50
## 5229 2
## 5230 22
## 5231 100
## 5232 997
## 5233 99
## 5234 54
## 5235 997
## 5236 31
## 5237 79
## 5238 6
## 5239 52
## 5240 0
## 5241 72
## 5242 54
## 5243 50
## 5244 79
## 5245 34
## 5246 100
## 5247 57
## 5248 997
## 5249 80
## 5250 100
## 5251 99
## 5252 52
## 5253 77
## 5254 91
## 5255 50
## 5256 49
## 5257 50
## 5258 75
## 5259 45
## 5260 30
## 5261 97
## 5262 80
## 5263 53
## 5264 21
## 5265 78
## 5266 53
## 5267 60
## 5268 100
## 5269 100
## 5270 52
## 5271 77
## 5272 100
## 5273 50
## 5274 69
## 5275 55
## 5276 65
## 5277 83
## 5278 100
## 5279 997
## 5280 46
## 5281 49
## 5282 1
## 5283 50
## 5284 92
## 5285 95
## 5286 59
## 5287 97
## 5288 99
## 5289 997
## 5290 97
## 5291 70
## 5292 25
## 5293 17
## 5294 32
## 5295 60
## 5296 62
## 5297 53
## 5298 40
## 5299 50
## 5300 72
## 5301 53
## 5302 97
## 5303 50
## 5304 84
## 5305 95
## 5306 51
## 5307 4
## 5308 98
## 5309 11
## 5310 99
## 5311 51
## 5312 65
## 5313 37
## 5314 100
## 5315 84
## 5316 50
## 5317 99
## 5318 99
## 5319 90
## 5320 4
## 5321 75
## 5322 50
## 5323 46
## 5324 93
## 5325 73
## 5326 99
## 5327 76
## 5328 49
## 5329 99
## 5330 99
## 5331 52
## 5332 0
## 5333 99
## 5334 86
## 5335 100
## 5336 38
## 5337 30
## 5338 29
## 5339 88
## 5340 99
## 5341 65
## 5342 59
## 5343 997
## 5344 90
## 5345 65
## 5346 69
## 5347 56
## 5348 55
## 5349 95
## 5350 997
## 5351 52
## 5352 57
## 5353 77
## 5354 86
## 5355 51
## 5356 85
## 5357 997
## 5358 90
## 5359 997
## 5360 997
## 5361 3
## 5362 59
## 5363 53
## 5364 55
## 5365 51
## 5366 46
## 5367 51
## 5368 100
## 5369 997
## 5370 53
## 5371 997
## 5372 50
## 5373 41
## 5374 997
## 5375 50
## 5376 35
## 5377 99
## 5378 49
## 5379 97
## 5380 64
## 5381 100
## 5382 68
## 5383 91
## 5384 50
## 5385 73
## 5386 92
## 5387 67
## 5388 59
## 5389 35
## 5390 997
## 5391 59
## 5392 100
## 5393 76
## 5394 80
## 5395 50
## 5396 50
## 5397 100
## 5398 80
## 5399 82
## 5400 88
## 5401 86
## 5402 23
## 5403 997
## 5404 59
## 5405 82
## 5406 50
## 5407 100
## 5408 997
## 5409 23
## 5410 1
## 5411 56
## 5412 71
## 5413 71
## 5414 50
## 5415 91
## 5416 60
## 5417 97
## 5418 69
## 5419 100
## 5420 52
## 5421 46
## 5422 0
## 5423 98
## 5424 100
## 5425 80
## 5426 76
## 5427 51
## 5428 92
## 5429 84
## 5430 89
## 5431 997
## 5432 64
## 5433 75
## 5434 100
## 5435 98
## 5436 997
## 5437 41
## 5438 100
## 5439 74
## 5440 997
## 5441 96
## 5442 100
## 5443 100
## 5444 69
## 5445 60
## 5446 80
## 5447 99
## 5448 51
## 5449 66
## 5450 78
## 5451 7
## 5452 997
## 5453 78
## 5454 47
## 5455 50
## 5456 22
## 5457 95
## 5458 1
## 5459 89
## 5460 97
## 5461 81
## 5462 89
## 5463 84
## 5464 46
## 5465 50
## 5466 62
## 5467 30
## 5468 52
## 5469 55
## 5470 79
## 5471 98
## 5472 56
## 5473 50
## 5474 61
## 5475 30
## 5476 67
## 5477 100
## 5478 54
## 5479 88
## 5480 69
## 5481 37
## 5482 97
## 5483 96
## 5484 997
## 5485 81
## 5486 39
## 5487 41
## 5488 100
## 5489 90
## 5490 66
## 5491 80
## 5492 28
## 5493 51
## 5494 70
## 5495 100
## 5496 100
## 5497 997
## 5498 98
## 5499 81
## 5500 100
## 5501 90
## 5502 86
## 5503 98
## 5504 74
## 5505 66
## 5506 78
## 5507 53
## 5508 98
## 5509 67
## 5510 3
## 5511 94
## 5512 63
## 5513 69
## 5514 1
## 5515 69
## 5516 80
## 5517 98
## 5518 47
## 5519 84
## 5520 61
## 5521 997
## 5522 44
## 5523 49
## 5524 93
## 5525 32
## 5526 64
## 5527 8
## 5528 5
## 5529 100
## 5530 64
## 5531 997
## 5532 27
## 5533 80
## 5534 66
## 5535 100
## 5536 50
## 5537 90
## 5538 94
## 5539 44
## 5540 997
## 5541 90
## 5542 50
## 5543 61
## 5544 84
## 5545 84
## 5546 69
## 5547 80
## 5548 100
## 5549 99
## 5550 100
## 5551 77
## 5552 1
## 5553 50
## 5554 99
## 5555 56
## 5556 79
## 5557 100
## 5558 100
## 5559 69
## 5560 98
## 5561 50
## 5562 36
## 5563 75
## 5564 93
## 5565 100
## 5566 4
## 5567 75
## 5568 60
## 5569 100
## 5570 46
## 5571 100
## 5572 100
## 5573 46
## 5574 91
## 5575 100
## 5576 51
## 5577 93
## 5578 90
## 5579 74
## 5580 51
## 5581 98
## 5582 87
## 5583 70
## 5584 25
## 5585 68
## 5586 74
## 5587 63
## 5588 79
## 5589 100
## 5590 64
## 5591 28
## 5592 99
## 5593 99
## 5594 43
## 5595 99
## 5596 55
## 5597 79
## 5598 96
## 5599 86
## 5600 85
## 5601 90
## 5602 97
## 5603 100
## 5604 61
## 5605 93
## 5606 71
## 5607 997
## 5608 99
## 5609 94
## 5610 96
## 5611 68
## 5612 92
## 5613 61
## 5614 83
## 5615 3
## 5616 59
## 5617 100
## 5618 93
## 5619 71
## 5620 997
## 5621 77
## 5622 97
## 5623 81
## 5624 70
## 5625 97
## 5626 64
## 5627 74
## 5628 53
## 5629 76
## 5630 59
## 5631 98
## 5632 99
## 5633 70
## 5634 51
## 5635 100
## 5636 88
## 5637 50
## 5638 75
## 5639 97
## 5640 1
## 5641 99
## 5642 69
## 5643 84
## 5644 100
## 5645 91
## 5646 71
## 5647 94
## 5648 81
## 5649 97
## 5650 95
## 5651 18
## 5652 14
## 5653 77
## 5654 97
## 5655 98
## 5656 51
## 5657 98
## 5658 65
## 5659 71
## 5660 997
## 5661 70
## 5662 98
## 5663 2
## 5664 49
## 5665 48
## 5666 97
## 5667 100
## 5668 68
## 5669 63
## 5670 75
## 5671 27
## 5672 997
## 5673 74
## 5674 98
## 5675 85
## 5676 61
## 5677 50
## 5678 19
## 5679 81
## 5680 51
## 5681 54
## 5682 50
## 5683 88
## 5684 81
## 5685 81
## 5686 997
## 5687 71
## 5688 94
## 5689 93
## 5690 48
## 5691 98
## 5692 99
## 5693 86
## 5694 59
## 5695 52
## 5696 81
## 5697 85
## 5698 98
## 5699 54
## 5700 100
## 5701 91
## 5702 96
## 5703 73
## 5704 100
## 5705 99
## 5706 99
## 5707 77
## 5708 80
## 5709 91
## 5710 91
## 5711 70
## 5712 90
## 5713 100
## 5714 997
## 5715 70
## 5716 96
## 5717 87
## 5718 14
## 5719 52
## 5720 78
## 5721 92
## 5722 51
## 5723 98
## 5724 87
## 5725 91
## 5726 83
## 5727 86
## 5728 62
## 5729 82
## 5730 98
## 5731 51
## 5732 10
## 5733 997
## 5734 64
## 5735 87
## 5736 90
## 5737 23
## 5738 99
## 5739 38
## 5740 100
## 5741 72
## 5742 99
## 5743 86
## 5744 2
## 5745 93
## 5746 98
## 5747 997
## 5748 997
## 5749 96
## 5750 95
## 5751 99
## 5752 41
## 5753 78
## 5754 93
## 5755 95
## 5756 85
## 5757 89
## 5758 59
## 5759 72
## 5760 95
## 5761 49
## 5762 100
## 5763 75
## 5764 87
## 5765 997
## 5766 45
## 5767 81
## 5768 99
## 5769 100
## 5770 66
## 5771 100
## 5772 94
## 5773 95
## 5774 100
## 5775 75
## 5776 100
## 5777 50
## 5778 75
## 5779 51
## 5780 85
## 5781 3
## 5782 100
## 5783 100
## 5784 92
## 5785 100
## 5786 51
## 5787 56
## 5788 99
## 5789 100
## 5790 997
## 5791 50
## 5792 90
## 5793 75
## 5794 99
## 5795 40
## 5796 85
## 5797 40
## 5798 99
## 5799 99
## 5800 49
## 5801 1
## 5802 95
## 5803 50
## 5804 57
## 5805 72
## 5806 997
## 5807 69
## 5808 58
## 5809 84
## 5810 100
## 5811 93
## 5812 99
## 5813 1
## 5814 92
## 5815 50
## 5816 49
## 5817 31
## 5818 77
## 5819 97
## 5820 49
## 5821 100
## 5822 56
## 5823 91
## 5824 66
## 5825 72
## 5826 80
## 5827 66
## 5828 65
## 5829 997
## 5830 89
## 5831 53
## 5832 48
## 5833 60
## 5834 89
## 5835 94
## 5836 997
## 5837 77
## 5838 96
## 5839 100
## 5840 100
## 5841 42
## 5842 81
## 5843 50
## 5844 45
## 5845 75
## 5846 77
## 5847 80
## 5848 79
## 5849 78
## 5850 100
## 5851 52
## 5852 100
## 5853 94
## 5854 78
## 5855 89
## 5856 9
## 5857 2
## 5858 77
## 5859 98
## 5860 51
## 5861 65
## 5862 51
## 5863 73
## 5864 99
## 5865 50
## 5866 50
## 5867 997
## 5868 87
## 5869 61
## 5870 99
## 5871 100
## 5872 70
## 5873 69
## 5874 100
## 5875 85
## 5876 47
## 5877 99
## 5878 72
## 5879 25
## 5880 78
## 5881 44
## 5882 997
## 5883 99
## 5884 61
## 5885 100
## 5886 88
## 5887 60
## 5888 91
## 5889 100
## 5890 84
## 5891 49
## 5892 85
## 5893 45
## 5894 100
## 5895 78
## 5896 97
## 5897 96
## 5898 95
## 5899 1
## 5900 62
DATA$ft_immig_2020Sep[DATA$ft_immig_2020Sep > 100] <- NA
theme.z <- theme(
axis.text.x = element_text(color = "black", size = 15),
axis.text.y = element_text(color = "black", size = 15),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
legend.position = "none",
panel.background = element_rect(fill = "gray90"),
panel.border = element_rect(color = "black", fill = NA, linewidth = 1.1),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_line(linewidth = 0.1, color = "white"),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.caption = element_text(size = 12 , hjust = 0, margin = margin(t = 10)),
plot.margin = unit(c(0.5,0.5,0.5,0.5), "cm"),
plot.title = element_text(face = "bold", size = 20, hjust = 0.5,margin = margin(b = 10)))
ggplot(data=DATA, mapping = aes(DATA$ft_immig_2020Sep)) +
geom_histogram(breaks = seq(-0.5,100.5, by = 1), mapping = aes(y = ..density..), col = "black", fill = "slategray4") +
labs(title = "Feeling thermometer ratings about immigrants\nall participants, unweighted", caption = "Data source: Sept 2020 wave of the Democracy Fund Voter Study Group. 2021.\nViews of the Electorate Research Survey. Washington, D.C. https://www.voterstudygroup.org/.") +
scale_y_continuous(labels=scales::percent_format(accuracy = 1), limits = c(-0.005,0.10), expand=c(0,0), breaks = seq(0,.10,.05), sec.axis = dup_axis()) +
scale_x_continuous(limits = c(-2.5,102.5), expand=c(0,0), breaks = seq(0,100,25)) +
theme.z
library(tidyverse)
X <- rnorm(800, mean = 11, sd = 3)
DATA <- data.frame(X)
theme.z <- theme(
axis.text.x = element_text(color = "black", size = 12),
axis.text.y = element_text(color = "black", size = 12),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_text(color = "black", size = 12),
legend.position = "none",
panel.background = element_rect(fill = "gray90"),
panel.border = element_rect(color = "black", fill = NA, size = 1.1),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_line(linewidth = 0.1, color = "gray80"),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.caption = element_text(size = 12 , hjust = 0, margin = margin(t = 10)),
plot.margin = unit(c(0.5,0.5,0.5,0.5), "cm"),
plot.title = element_text(face = "bold", size = 14, hjust = 0.5,margin = margin(b = 10)))
ggplot(data = DATA, aes(X)) +
geom_histogram(breaks = seq(-0.5,20.5, by = 1), aes(y = ..count..), col = "black", fill = "dodgerblue", size = 1) +
scale_y_continuous(limits = c(0,120), expand = c(0,0), breaks = seq(0,120,10), sec.axis = sec_axis(trans = ~. /length(X), labels=scales::percent_format(accuracy = 1), name = "Frequency")) +
scale_x_continuous(limits = c(0, 25), expand = c(0,0), breaks = seq(1,24,1)) +
labs(x = "X", y = "Count") +
theme.z
library(tidyverse)
DATA <- read_csv("states.csv")
theme.z <- theme(
axis.text.x = element_text(size = 15, color = "black", hjust = 0.5, margin = margin(t = 8, b = 8)),
axis.text.y = element_text(size = 15, color = "black", vjust = 0.5, margin = margin(r = 7, l = 7)),
axis.text.y.right = element_text(size = 15, color = "black", vjust = 0.5, margin = margin(r = 7, l = 7)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_text(size = 15, color = "black", hjust = 0.5, margin = margin(t = 8, b = 8)),
axis.title.y = element_text(size = 15, color = "black", hjust = 1 , vjust = 0.5, margin = margin(l = 8, r = 8), angle=0),
axis.title.y.right = element_blank(),
panel.background = element_rect(linewidth = 0.5, fill = "gray90"),
panel.border = element_rect(linewidth = 1.8, fill = NA ),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 12, hjust = 0 , margin = margin(t = 10)),
plot.margin = unit(c(t = 10, r = 10, b = 10, l = 10),"pt"),
plot.subtitle = element_text(size = 15, hjust = 0.5, margin = margin(t = 0, b = 8)),
plot.title = element_text(size = 20, hjust = 0.5, margin = margin(t = 0, b = 16), face = "bold")
)
summary(DATA$PctReligVery)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 16.00 31.00 36.50 37.16 43.75 59.00
summary(DATA$PctEatProduceFreq)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 52.10 55.73 57.35 57.50 59.45 64.60
summary(lm(DATA$PctReligVery ~ DATA$PctEatProduceFreq))
##
## Call:
## lm(formula = DATA$PctReligVery ~ DATA$PctEatProduceFreq)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.998 -5.091 -1.438 4.140 19.056
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 143.8881 19.8256 7.258 2.96e-09 ***
## DATA$PctEatProduceFreq -1.8561 0.3443 -5.390 2.11e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.213 on 48 degrees of freedom
## Multiple R-squared: 0.3771, Adjusted R-squared: 0.3641
## F-statistic: 29.06 on 1 and 48 DF, p-value: 2.107e-06
ggplot(data = DATA, mapping = aes(y = PctReligVery, x = PctEatProduceFreq)) +
geom_smooth(method="lm", color = "blue", se=FALSE, fullrange=TRUE) +
geom_point(size = 3.5) +
scale_x_continuous(limits = c(50,70), breaks = seq(50,70,5)) +
scale_y_continuous(limits = c(0,100), breaks = seq(0,100,10), labels = seq(0,100,10), expand = c(0,0),
sec.axis = dup_axis()) +
labs(x = "Percentage of state residents that\neat produce frequently", y = "Percentage of\nstate residents\nthat are\nvery religious") +
annotate("text", x = 70, y = 88, size = 4, hjust = 1, family = "mono", label = " Estimate p-value") +
annotate("text", x = 70, y = 80, size = 4, hjust = 1, family = "mono", label = " Intercept 143.89 <0.01") +
annotate("text", x = 70, y = 72, size = 4, hjust = 1, family = "mono", label = "% eat produce freq -1.86 <0.01") +
theme.z
library(tidyverse)
library(usmap)
DATA <- tribble(
~state, ~PCTBLACK,
"Alabama" , 26.2, "Alaska" , 3.3, "Arizona" , 4.1, "Arkansas" , 15.4,
"California" , 6.2, "Colorado" , 4 , "Connecticut" , 10.1, "Delaware" , 21.4,
"Florida" , 16 , "Georgia" , 30.5, "Hawaii" , 1.6, "Idaho" , 0.6,
"Illinois" , 14.5, "Indiana" , 9.1, "Iowa" , 2.9, "Kansas" , 5.9,
"Kentucky" , 7.8, "Louisiana" , 32 , "Maine" , 1.2, "Maryland" , 29.4,
"Massachusetts" , 6.6, "Michigan" , 14.2, "Minnesota" , 5.2, "Mississippi" , 37 ,
"Missouri" , 11.6, "Montana" , 0.4, "Nebraska" , 4.5, "Nevada" , 8.1,
"New Hampshire" , 1.1, "New Jersey" , 13.7, "New Mexico" , 2.1, "New York" , 15.9,
"North Carolina", 21.5, "North Dakota" , 1.2, "Ohio" , 12.2, "Oklahoma" , 7.4,
"Oregon" , 1.8, "Pennsylvania" , 10.8, "Rhode Island" , 5.7, "South Carolina", 27.9,
"South Dakota" , 1.3, "Tennessee" , 16.7, "Texas" , 11.8, "Utah" , 1.1,
"Vermont" , 1 , "Virginia" , 19.4, "Washington" , 3.6, "West Virginia" , 3.4,
"Wisconsin" , 6.3, "Wyoming" , 1 )
theme.z <- theme(
legend.position = "right",
legend.text = element_text(size = 15),
legend.title = element_text(size = 15, face = "bold"),
plot.margin = unit(c(t = 10,r = 10,b = 10,l = 10),"pt"),
plot.title = element_text(size = 20, hjust = 0.5, face = "bold", margin = margin(t = 0,b = 0))
)
plot_usmap(data = DATA, values = "PCTBLACK", color = "black", lwd = 0.75) +
scale_fill_continuous(low = "lightblue1", high = "darkblue", breaks = c(0,5,10,20,30,35)) +
guides(fill = guide_legend("Percent\nBlack")) +
labs(title = "Title") +
theme.z
library(ggplot2)
library(maps)
library(rnaturalearth, rnaturalearthdata)
library(sf)
DATA <- read_csv("world map.csv")
print(DATA, n = Inf)
## # A tibble: 222 × 3
## region CountryCode NUMBERS
## <chr> <chr> <dbl>
## 1 Afghanistan AFG 8
## 2 Albania ALB 6
## 3 Algeria DZA 6
## 4 American Samoa ASM 6
## 5 Andorra AND 8
## 6 Angola AGO 2
## 7 Antigua ATG 4
## 8 Argentina ARG 5
## 9 Armenia ARM 9
## 10 Aruba ABW 7
## 11 Australia AUS 5
## 12 Austria AUT 3
## 13 Azerbaijan AZE 1
## 14 Bahamas BHS 4
## 15 Bahrain BHR 3
## 16 Bangladesh BGD 9
## 17 Barbados BRB 0
## 18 Belarus BLR 9
## 19 Belgium BEL 3
## 20 Belize BLZ 4
## 21 Benin BEN 2
## 22 Bermuda BMU 4
## 23 Bhutan BTN 9
## 24 Bolivia BOL 9
## 25 Bosnia and Herzegovina BIH 4
## 26 Botswana BWA 3
## 27 Brazil BRA 6
## 28 Virgin Islands VGB 1
## 29 Brunei BRN 4
## 30 Bulgaria BGR 5
## 31 Burkina Faso BFA 5
## 32 Burundi BDI 0
## 33 Cabo Verde CPV 2
## 34 Cambodia KHM 0
## 35 Cameroon CMR 2
## 36 Canada CAN 2
## 37 Cayman Islands CYM 3
## 38 Central African Republic CAF 6
## 39 Central Europe and the Baltics CEB 2
## 40 Chad TCD 3
## 41 Channel Islands CHI 8
## 42 Chile CHL 2
## 43 China CHN 3
## 44 Colombia COL 1
## 45 Comoros COM 6
## 46 Democratic Republic of the Congo COD 0
## 47 Republic of Congo COG 1
## 48 Costa Rica CRI 8
## 49 Cote d'Ivoire CIV 1
## 50 Croatia HRV 9
## 51 Cuba CUB 5
## 52 Curacao CUW 3
## 53 Cyprus CYP 1
## 54 Czech Republic CZE 6
## 55 Denmark DNK 9
## 56 Djibouti DJI 8
## 57 Dominica DMA 6
## 58 Dominican Republic DOM 6
## 59 Ecuador ECU 4
## 60 Egypt EGY 8
## 61 El Salvador SLV 3
## 62 Equatorial Guinea GNQ 1
## 63 Eritrea ERI 6
## 64 Estonia EST 3
## 65 Eswatini SWZ 4
## 66 Ethiopia ETH 3
## 67 Faroe Islands FRO 5
## 68 Fiji FJI 0
## 69 Finland FIN 6
## 70 France FRA 9
## 71 French Polynesia PYF 9
## 72 Gabon GAB 3
## 73 Gambia GMB 2
## 74 Georgia GEO 2
## 75 Germany DEU 5
## 76 Ghana GHA 4
## 77 Gibraltar GIB 2
## 78 Greece GRC 4
## 79 Greenland GRL NA
## 80 Grenada GRD 2
## 81 Guam GUM 2
## 82 Guatemala GTM 0
## 83 Guinea GIN 3
## 84 Guinea-Bissau GNB 4
## 85 Guyana GUY 5
## 86 Haiti HTI 1
## 87 Honduras HND 7
## 88 Hong Kong SAR, China HKG 5
## 89 Hungary HUN 0
## 90 Iceland ISL 1
## 91 India IND 7
## 92 Indonesia IDN 7
## 93 Iran IRN 3
## 94 Iraq IRQ 3
## 95 Ireland IRL 5
## 96 Isle of Man IMN 6
## 97 Israel ISR 7
## 98 Italy ITA 7
## 99 Jamaica JAM 2
## 100 Japan JPN 8
## 101 Jordan JOR 4
## 102 Kazakhstan KAZ 7
## 103 Kenya KEN 0
## 104 Kiribati KIR 8
## 105 North Korea PRK 3
## 106 South Korea KOR 8
## 107 Kosovo XKX 0
## 108 Kuwait KWT 2
## 109 Kyrgyz Republic KGZ 5
## 110 Lao PDR LAO 9
## 111 Latvia LVA 8
## 112 Least developed countries: UN classification LDC 4
## 113 Lebanon LBN 9
## 114 Lesotho LSO 6
## 115 Liberia LBR 2
## 116 Libya LBY 2
## 117 Liechtenstein LIE 8
## 118 Lithuania LTU 1
## 119 Luxembourg LUX 6
## 120 Macao SAR, China MAC 4
## 121 Madagascar MDG 6
## 122 Malawi MWI 5
## 123 Malaysia MYS 0
## 124 Maldives MDV 2
## 125 Mali MLI 1
## 126 Malta MLT 4
## 127 Marshall Islands MHL 6
## 128 Mauritania MRT 4
## 129 Mauritius MUS 2
## 130 Mexico MEX 4
## 131 Micronesia FSM 6
## 132 Moldova MDA 7
## 133 Monaco MCO 7
## 134 Mongolia MNG 8
## 135 Montenegro MNE 9
## 136 Morocco MAR 9
## 137 Mozambique MOZ 0
## 138 Myanmar MMR 2
## 139 Namibia NAM 5
## 140 Nauru NRU 1
## 141 Nepal NPL 6
## 142 Netherlands NLD 6
## 143 New Caledonia NCL 8
## 144 New Zealand NZL 6
## 145 Nicaragua NIC 6
## 146 Niger NER 6
## 147 Nigeria NGA 7
## 148 North America NAC 0
## 149 North Macedonia MKD 2
## 150 Northern Mariana Islands MNP 6
## 151 Norway NOR 0
## 152 Not classified INX 2
## 153 Oman OMN 9
## 154 Pakistan PAK 1
## 155 Palau PLW 3
## 156 Panama PAN 5
## 157 Papua New Guinea PNG 5
## 158 Paraguay PRY 2
## 159 Peru PER 8
## 160 Philippines PHL 0
## 161 Poland POL 2
## 162 Portugal PRT 2
## 163 Puerto Rico PRI 1
## 164 Qatar QAT 6
## 165 Romania ROU 5
## 166 Russian Federation RUS 0
## 167 Rwanda RWA 8
## 168 Samoa WSM 3
## 169 San Marino SMR 4
## 170 Sao Tome and Principe STP 3
## 171 Saudi Arabia SAU 4
## 172 Senegal SEN 2
## 173 Serbia SRB 6
## 174 Seychelles SYC 2
## 175 Sierra Leone SLE 5
## 176 Singapore SGP 9
## 177 Sint Maarten SXM 3
## 178 Slovak Republic SVK 4
## 179 Slovenia SVN 9
## 180 Solomon Islands SLB 0
## 181 Somalia SOM 4
## 182 South Africa ZAF 5
## 183 South Sudan SSD 7
## 184 Spain ESP 5
## 185 Sri Lanka LKA 7
## 186 St. Kitts and Nevis KNA 6
## 187 St. Lucia LCA 0
## 188 St. Martin MAF 1
## 189 St. Vincent and the Grenadines VCT 9
## 190 Sudan SDN 5
## 191 Suriname SUR 7
## 192 Sweden SWE 2
## 193 Switzerland CHE 2
## 194 Syrian Arab Republic SYR 2
## 195 Tajikistan TJK 7
## 196 Tanzania TZA 8
## 197 Thailand THA 0
## 198 Timor-Leste TLS 7
## 199 Togo TGO 4
## 200 Tonga TON 9
## 201 Trinidad and Tobago TTO 6
## 202 Tunisia TUN 5
## 203 Turkey TUR 6
## 204 Turkmenistan TKM 7
## 205 Turks and Caicos Islands TCA 8
## 206 Tuvalu TUV 2
## 207 Uganda UGA 3
## 208 Ukraine UKR 8
## 209 United Arab Emirates ARE 2
## 210 United Kingdom GBR 2
## 211 Uruguay URY 1
## 212 USA USA 9
## 213 Uzbekistan UZB 2
## 214 Vanuatu VUT 0
## 215 Venezuela VEN 6
## 216 Vietnam VNM 1
## 217 Virgin Islands (U.S.) VIR 8
## 218 West Bank and Gaza PSE 7
## 219 World WLD 5
## 220 Yemen YEM 8
## 221 Zambia ZMB 7
## 222 Zimbabwe ZWE 5
WORLD <- st_as_sf(map("world", plot = FALSE, fill = TRUE))
SUM <- merge(WORLD, DATA, by.x = c("ID"), by.y = c("region"))
theme.z <- theme(
axis.text = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
legend.box = "horizontal",
legend.position = "bottom",
panel.border = element_blank(),
panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
rect = element_blank()
)
ggplot(data = SUM) +
geom_sf(mapping = aes(fill = NUMBERS),color = "black", linewidth = 0.5) +
scale_fill_continuous(low = "lightsteelblue1", high = "royalblue4", limits = c(0,9), breaks = c(0,3,6,9)) +
guides(fill = guide_legend("Some data")) +
# coord_sf(xlim = c(60,100), ylim = c(0,50)) +
theme.z
library(maps)
library(rnaturalearth)
library(rnaturalearthdata)
library(tidyverse)
WORLD <- ne_countries(scale = "medium", returnclass = "sf")
IRAN <- ne_countries(country = "iran", type = "countries", scale = "medium", returnclass = "sf")
ggplot() +
geom_sf(data = WORLD) +
geom_sf(data = IRAN, linewidth = 1.2, color = "black", fill = "darkolivegreen3") +
coord_sf(xlim = c(40,68), ylim = c(22,46), expand = FALSE, datum = NA) +
geom_point(data = NULL, mapping = aes(x = 50.99155, y = 35.83266), shape = 21, color = "black", fill = "red", size = 4, stroke = 1.2) +
annotate("text", x = 50.99155, y = 35.2, label = "Karaj", size = 5 , color = "black", vjust = "top") +
annotate("text", x = 54 , y = 32 , label = "Iran" , size = 10, color = "black") +
theme(
axis.title = element_blank(),
panel.border = element_rect(linewidth = 1.0, color = "black", fill = NA)
)
sort of as a pie chart (colors better in grayscale)
library(patchwork)
library(waffle)
theme.z <- theme(
legend.text = element_text(size = 15),
plot.caption = element_blank(),
plot.subtitle = element_text(face = "bold", margin = margin(t = 0, b = 6), size = 16, hjust = 0),
plot.title = element_text(face = "bold", margin = margin(t = 0, b = 6), size = 20, hjust = 0))
BIO.BWA <- c("Category 1 only (14%)" = 14, "Category 1 and 2 (11%)" = 11, "Category 2 only (24%)" = 24, "Neither 1 nor 2 (51%)" = 51)
BIO.BWA.BIO <- c("Category 1 only (20%)" = 20, "Category 1 and 2 (14%)" = 14, "Category 1 only (23%)" = 23, "Neither 1 nor 2 (43%)" = 43)
p1 <- waffle(BIO.BWA, rows = 5, size = 2, colors = c("slategray1","purple4","lightpink1","gray70")) +
labs(title = "Title of the first plot", subtitle = "Subtitle of the first plot") +
theme.z
p2 <- waffle(BIO.BWA.BIO, rows = 5, size = 2, colors = c("slategray1","purple4","lightpink1","gray70")) +
labs(title = "Title of the second plot", subtitle = "Subtitle of the second plot", caption = "Sample size 1,500 U.S. adults. Estimates are weighted.\nData source:") +
theme.z +
theme(plot.caption = element_text(size = 11, hjust = 0, margin = margin(10,0,0,0)),
plot.title = element_text(face = "bold", margin = margin(t = 10, b = 6), size = 20, hjust = 0)
)
p1 / p2
library(tidyverse)
DATA <- tribble(
~MOD, ~X, ~Y,
0, 0, 30,
0, 1, 55,
1, 0, 50,
1, 1, 70)
theme.z <- theme(
plot.background = element_rect(fill = "white"),
plot.margin = unit(c(0.5,0.9,0.5,4.2),"cm"),
plot.title = element_text(face = "bold", margin = margin(t = 0, b = 12), size = 18, hjust = 0.5),
plot.subtitle = element_text(size = 12, hjust = 0.5),
plot.caption = element_text(size = 9, hjust = 1),
strip.background = element_rect(linewidth = 1.0, color = "black", fill = "black"),
strip.text.x = element_text(size = 14, color = "white", face = "bold"),
panel.background = element_rect(fill = "gray90", color = "black", linewidth = 0.5, linetype = "solid"),
panel.border = element_rect(fill = NA, color = "black", linetype = "solid", linewidth = 1.0),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
panel.spacing.x = unit(2, "lines"),
panel.spacing.y = unit(1, "lines"),
axis.text.x = element_text(size = 15, color = "black", margin = margin(t = 7, b = 5)),
axis.text.y = element_text(size = 15, color = "black", margin = margin(r = 7)),
axis.ticks.y = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_text(size = 15, color = "black", angle = 0, vjust = 1),
axis.title.y.right = element_text(size = 15, color = "black", angle = 0, vjust = 1),
axis.title.x = element_text(size = 15, color = "black")
)
ggplot(DATA, mapping = aes(x = X, y = Y, group = MOD)) +
geom_smooth(data = subset(DATA, MOD == 0), method = "lm", formula = y~x, se = F, linewidth = 1, color = "blue") +
geom_smooth(data = subset(DATA, MOD == 1), method = "lm", formula = y~x, se = F, linewidth = 2, color = "pink") +
geom_point(pch = 21, size = 4, stroke = 1.5, color = "black", bg = "white") +
scale_x_continuous(name = "X", breaks = seq(0,1,1), expand = c(0,0), limits = c(-0.05,1.05)) +
scale_y_continuous(name = "Y", breaks = c(0,30,50), expand = c(0,0), limits = c(0,76), sec.axis = sec_axis(~., name = "Y", breaks = c(55,70))) +
annotate("text", x = 0.3, y = 26, label = "OLS Coefficients", hjust = 0, vjust = 1, size = 6, lineheight = 0.9, family = "mono", fontface = "bold") +
annotate("text", x = 0.3, y = 21, label = " 30 Intercept\n 20 Female\n 25 X\n -5 Female * X", hjust = 0, vjust = 1, size = 6, lineheight = 0.9, family = "mono") +
geom_text(x = 0.5, y = 41, label = "Slope for males of 25" , hjust = 0.5, vjust = 1, size = 5.6, angle = 19.5) +
geom_text(x = 0.5, y = 66, label = "Slope for females of 20", hjust = 0.5, vjust = 1, size = 5.6, angle = 16) +
geom_text(x = -0.25, y = 15, label = "Intercept\nof 30", hjust = 1, vjust = 0.5, size = 5.6) +
geom_text(x = -0.25, y = 40, label = "\"Female\"\ncoefficient\nof 20", hjust = 1, vjust = 0.5, size = 5.6) +
geom_segment(x = -0.2, y = 0, xend = -0.2, yend = 30, arrow = arrow(length = unit(10, "pt"), ends = "both")) +
geom_segment(x = -0.2, y = 50, xend = -0.2, yend = 30, arrow = arrow(length = unit(10, "pt"), ends = "both")) +
coord_cartesian(clip = "off") +
theme.z
summary(lm(Y ~ X*MOD, data = DATA))
##
## Call:
## lm(formula = Y ~ X * MOD, data = DATA)
##
## Residuals:
## ALL 4 residuals are 0: no residual degrees of freedom!
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 30 NaN NaN NaN
## X 25 NaN NaN NaN
## MOD 20 NaN NaN NaN
## X:MOD -5 NaN NaN NaN
##
## Residual standard error: NaN on 0 degrees of freedom
## Multiple R-squared: 1, Adjusted R-squared: NaN
## F-statistic: NaN on 3 and 0 DF, p-value: NA
library(ggpubr)
library(tidyverse)
DATA <- tribble(
~HEALTH, ~VEGGIE, ~EXERCISE,
6, 0, 0,
5, 1, 0,
4, 2, 0,
51, 3, 1,
65, 4, 1,
65, 5, 1,
75, 6, 1,
66, 7, 1)
theme.z <- theme(
axis.text.x = element_text(size = 15, color = "black", margin = margin(t = 7,b = 7)),
axis.text.y = element_text(size = 15, color = "black", margin = margin(l = 7,r = 7)),
axis.text.y.right = element_text(size = 15, color = "black", margin = margin(l = 7,r = 7)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_text(size = 15, color = "black", margin = margin(t = 7,r = 7,b = 7,l = 7)),
axis.title.y = element_text(size = 15, color = "black", margin = margin(t = 7,r = 7,b = 7,l = 7)),
legend.position = "none",
panel.background = element_rect(linewidth = 1.0, color = "black", fill = "gray90", linetype = "solid"),
panel.border = element_rect(linewidth = 1.0, color = "black", fill = NA, linetype = "solid"),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
panel.spacing.x = unit(1, "lines"),
panel.spacing.y = unit(1, "lines"),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 12, hjust = 0 , margin = margin(t = 10)),
plot.margin = unit(c(t = 5,r = 5,b = 5,l = 5),"pt"),
plot.subtitle = element_text(size = 15, hjust = 0.5, margin = margin(b = 7)),
plot.title = element_text(size = 20, hjust = 0.5, face = "bold", margin = margin(t = 0,b = 12))
)
ggplot(data=DATA, mapping = aes(x = VEGGIE, y = HEALTH)) +
geom_smooth(data=subset(DATA, EXERCISE==1), formula = y ~ x, method="lm", se=FALSE, fullrange=TRUE, color = "green2", linewidth = 1.2) +
geom_smooth(data=subset(DATA, EXERCISE==0), formula = y ~ x, method="lm", se=FALSE, fullrange=TRUE, color = "red", linewidth = 1.2) +
geom_point(size = 4) +
geom_point(data=subset(DATA, EXERCISE==0), size = 4, pch=21, stroke = 1.2, fill = "red") +
geom_point(data=subset(DATA, EXERCISE==1), size = 4, pch=21, stroke = 1.2, fill = "green2") +
scale_x_continuous(name="VEGGIE\n(Number of days per week eating vegetables)", expand=c(0,0), limits = c(-0.5,7.5) , breaks = seq(0,7,1)) +
scale_y_continuous(name="HEALTH", limits = c(-5,100), breaks = seq(0,100,20)) +
geom_bracket(xmin=0, xmax = 2, label = "No exercise\nEXERCISE=0", y.position=15, label.size = 5.5, vjust = -0.2, tip.length=c(0.05 ,0.1)) +
geom_bracket(xmin=3, xmax = 7, label = "Exercises\nEXERCISE=1" , y.position=35, label.size = 5.5, vjust = 2.8, tip.length=c(-0.15, -0.35)) +
labs(title = "Health rating") +
theme.z
library(tidyverse)
DATA <- tribble(
~AGE, ~ITEM, ~RACE, ~PCT, ~CILO, ~CIHI,
"Age 18-29","0 to 24","Whites",0.1686075,0.125517,0.2227235,
"Age 18-29","25 to 49","Whites",0.2258218,0.1745539,0.2869135,
"Age 18-29","50","Whites",0.0491381,0.027793,0.0854356,
"Age 18-29","51 to 75","Whites",0.2707414,0.2160958,0.3333297,
"Age 18-29","76 to 100","Whites",0.2841337,0.2276716,0.3482837,
"Age 18-29","0 to 24","Blacks",0.4298258,0.2903636,0.5813931,
"Age 18-29","25 to 49","Blacks",0.3173413,0.1963695,0.4693152,
"Age 18-29","50","Blacks",0.048522,0.0089412,0.2237587,
"Age 18-29","51 to 75","Blacks",0.1696017,0.0965342,0.2807865,
"Age 18-29","76 to 100","Blacks",0.0347092,0.0093621,0.1203453,
"Age 18-29","0 to 24","Hispanics",0.2210459,0.1426287,0.3261748,
"Age 18-29","25 to 49","Hispanics",0.1639248,0.1095114,0.2381445,
"Age 18-29","50","Hispanics",0.1007021,0.0496316,0.1936177,
"Age 18-29","51 to 75","Hispanics",0.2340969,0.1579551,0.3324516,
"Age 18-29","76 to 100","Hispanics",0.2802302,0.1932706,0.3875214,
"Age 18-29","0 to 24","Other",0.1799807,0.1005913,0.3010538,
"Age 18-29","25 to 49","Other",0.2835058,0.1587469,0.4534617,
"Age 18-29","50","Other",0.0279455,0.0065446,0.111475,
"Age 18-29","51 to 75","Other",0.3626855,0.2336636,0.5150665,
"Age 18-29","76 to 100","Other",0.1458826,0.0655658,0.2936658,
"Age 30-45","0 to 24","Whites",0.0880538,0.0688471,0.1119744,
"Age 30-45","25 to 49","Whites",0.1490723,0.1252224,0.1765479,
"Age 30-45","50","Whites",0.0528802,0.0363371,0.0763582,
"Age 30-45","51 to 75","Whites",0.2651047,0.2341556,0.2985497,
"Age 30-45","76 to 100","Whites",0.444889,0.4087117,0.48166,
"Age 30-45","0 to 24","Blacks",0.2473897,0.1837595,0.3242992,
"Age 30-45","25 to 49","Blacks",0.3215109,0.2441783,0.4100479,
"Age 30-45","50","Blacks",0.0686421,0.0413368,0.1118792,
"Age 30-45","51 to 75","Blacks",0.2180175,0.1547748,0.2979913,
"Age 30-45","76 to 100","Blacks",0.1178969,0.0727645,0.1854246,
"Age 30-45","0 to 24","Hispanics",0.1405747,0.0891829,0.2146035,
"Age 30-45","25 to 49","Hispanics",0.1712986,0.1257236,0.229066,
"Age 30-45","50","Hispanics",0.060349,0.0333786,0.1067063,
"Age 30-45","51 to 75","Hispanics",0.3072251,0.2453594,0.3768989,
"Age 30-45","76 to 100","Hispanics",0.3205526,0.2582513,0.3899815,
"Age 30-45","0 to 24","Other",0.1252955,0.0775243,0.1962415,
"Age 30-45","25 to 49","Other",0.1951634,0.1266456,0.2885051,
"Age 30-45","50","Other",0.0762974,0.0382879,0.1463,
"Age 30-45","51 to 75","Other",0.3186173,0.2348634,0.4159998,
"Age 30-45","76 to 100","Other",0.2846264,0.2003887,0.3871309,
"Age 46-59","0 to 24","Whites",0.0289146,0.0183031,0.045394,
"Age 46-59","25 to 49","Whites",0.0765872,0.0587539,0.0992624,
"Age 46-59","50","Whites",0.031878,0.0207482,0.0486813,
"Age 46-59","51 to 75","Whites",0.2623021,0.2280894,0.2996544,
"Age 46-59","76 to 100","Whites",0.6003181,0.5594169,0.6398667,
"Age 46-59","0 to 24","Blacks",0.2029044,0.1311466,0.3003523,
"Age 46-59","25 to 49","Blacks",0.2460165,0.171898,0.3390102,
"Age 46-59","50","Blacks",0.0785931,0.0413865,0.1442167,
"Age 46-59","51 to 75","Blacks",0.2879665,0.2003525,0.3949698,
"Age 46-59","76 to 100","Blacks",0.1845194,0.1238305,0.2659244,
"Age 46-59","0 to 24","Hispanics",0.0790971,0.0343998,0.1715537,
"Age 46-59","25 to 49","Hispanics",0.1759927,0.1123977,0.2648339,
"Age 46-59","50","Hispanics",0.0705534,0.0347834,0.1378541,
"Age 46-59","51 to 75","Hispanics",0.2658014,0.184284,0.3671479,
"Age 46-59","76 to 100","Hispanics",0.4085554,0.3102326,0.5147835,
"Age 46-59","0 to 24","Other",0.0394191,0.0110365,0.1311161,
"Age 46-59","25 to 49","Other",0.1522902,0.0886397,0.2491515,
"Age 46-59","50","Other",0.0303505,0.0095767,0.0920012,
"Age 46-59","51 to 75","Other",0.4064893,0.2907918,0.5335858,
"Age 46-59","76 to 100","Other",0.371451,0.2611008,0.4970653,
"Age 60+","0 to 24","Whites",0.0101233,0.0053504,0.0190725,
"Age 60+","25 to 49","Whites",0.0534469,0.0415213,0.0685529,
"Age 60+","50","Whites",0.013854,0.008874,0.0215679,
"Age 60+","51 to 75","Whites",0.2511503,0.2264746,0.2775499,
"Age 60+","76 to 100","Whites",0.6714254,0.6426687,0.698952,
"Age 60+","0 to 24","Blacks",0.0897313,0.0426382,0.1791068,
"Age 60+","25 to 49","Blacks",0.1742434,0.1083386,0.2681815,
"Age 60+","50","Blacks",0.043537,0.0206152,0.0896133,
"Age 60+","51 to 75","Blacks",0.4234502,0.3277676,0.5252404,
"Age 60+","76 to 100","Blacks",0.2562281,0.1733786,0.3613605,
"Age 60+","0 to 24","Hispanics",0.0609062,0.0219529,0.157825,
"Age 60+","25 to 49","Hispanics",0.0339614,0.0126179,0.0881835,
"Age 60+","50","Hispanics",0.0365783,0.013317,0.0964974,
"Age 60+","51 to 75","Hispanics",0.2722974,0.1807325,0.3882669,
"Age 60+","76 to 100","Hispanics",0.5962568,0.4774693,0.7047391,
"Age 60+","0 to 24","Other",0.0201068,0.0059742,0.0654697,
"Age 60+","25 to 49","Other",0.074297,0.0319437,0.1633308,
"Age 60+","50","Other",0.028154,0.0082708,0.0914298,
"Age 60+","51 to 75","Other",0.1951647,0.1240613,0.293371,
"Age 60+","76 to 100","Other",0.6822776,0.5659573,0.7795664)
theme.z <- theme(
panel.background = element_rect(fill = "black"),
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
panel.border = element_rect(color = "black", linewidth = 1, fill = NA),
panel.spacing.x = unit(1, "lines"),
panel.spacing.y = unit(0.5, "lines"),
strip.background = element_rect(linewidth = 1, color = "black", fill = "black"),
strip.text.x = element_text(color = "white", face = "bold", size = 15),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_text(color = "black", size = 12),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
plot.title = element_text(face = "bold", margin = margin(t = 0, b = 13), size = 16, hjust = 0.5),
plot.subtitle = element_text(hjust = 0.5),
plot.caption = element_text(size = 10, hjust = 0, margin = margin(10,0,0,0)),
legend.text = element_text(size = 12),
legend.position = "bottom"
)
DATA$AGE <- factor(DATA$AGE , levels = c("Age 18-29", "Age 30-45", "Age 46-59", "Age 60+"))
DATA$ITEM <- factor(DATA$ITEM, levels = rev(c("0 to 24", "25 to 49", "50", "51 to 75", "76 to 100")))
DATA$RACE <- factor(DATA$RACE, levels = c("Whites", "Blacks", "Hispanics", "Other"))
AGE.ORDER <- rev(c("Age 18-29", "Age 30-45", "Age 46-59", "Age 60+"))
RACE.ORDER <- c("Other", "Hispanics", "Blacks", "Whites")
CAPTION <- str_wrap("Plot indicates percentages in each group. Overall sample sizes: Whites 3,701. Blacks 539. Hispanics 647. Other 384.\nData source: American National Election Studies. 2021.\nANES 2020 Social Media Study: Pre-Election Data [dataset and documentation]. March 8, 2021 version. www.electionstudies.org", width = 100)
ggplot(DATA, mapping = aes(x = AGE, y = 100*PCT, fill = ITEM)) +
geom_col(color = "black", linewidth = 1.1, width = 0.8) +
scale_fill_manual(values = rev(c("red3", "red1", "white", "green1", "green3")), name = "Rating") +
coord_flip() +
facet_wrap(~RACE, ncol = 4, dir = "h") +
scale_x_discrete(limits = AGE.ORDER, labels = AGE.ORDER, name = "") +
scale_y_continuous(limits = c(0, 100.01)) +
labs(title = "Ratings of Police on 0-to-100 Feeling Thermometers", caption = CAPTION) +
theme.z + guides(fill = guide_legend(reverse = T))
ggplot(DATA, mapping = aes(x = RACE, y = 100*PCT, fill = ITEM)) +
geom_col(color = "black", linewidth = 1.1, width = 0.8) +
scale_fill_manual(values = rev(c("red3", "red1", "white", "green1", "green3")), name = "Rating") +
coord_flip() +
facet_wrap(~AGE, ncol = 4, dir = "h") +
scale_x_discrete(limits = RACE.ORDER, labels = RACE.ORDER, name = "") +
scale_y_continuous(limits = c(0, 100.01)) +
labs(title = "Ratings of Police on 0-to-100 Feeling Thermometers", caption = CAPTION) +
theme.z + guides(fill = guide_legend(reverse = T))
library(patchwork)
library(tidyverse)
DATA <- tribble(
~CONTROLS,~GROUP,~LEVEL,~PE,~CILO,~CIHI,
"Small controls","Ratings about Blacks","0 to 24",0.0461706,0.0270992,0.0652419,
"Small controls","Ratings about Blacks","25 to 49",0.0982854,0.0768214,0.1197495,
"Small controls","Ratings about Blacks","at 50",0.0754165,0.0575844,0.0932486,
"Small controls","Ratings about Blacks","51 to 85",0.1596652,0.146106,0.1732243,
"Small controls","Ratings about Blacks","86 to 99",0.2926404,0.2711568,0.3141241,
"Small controls","Ratings about Blacks","at 100",0.4549532,0.4144586,0.4954477,
"Small controls","Ratings about Whites","0 to 24",0.4226789,0.3650292,0.4803286,
"Small controls","Ratings about Whites","25 to 49",0.4011842,0.3655237,0.4368447,
"Small controls","Ratings about Whites","at 50",0.2425766,0.211447,0.2737062,
"Small controls","Ratings about Whites","51 to 85",0.2040362,0.1888231,0.2192493,
"Small controls","Ratings about Whites","86 to 99",0.1029744,0.0892483,0.1167005,
"Small controls","Ratings about Whites","at 100",0.0746247,0.057398,0.0918514,
"Full controls","Ratings about Blacks","0 to 24",0.0608033,0.0342018,0.0874048,
"Full controls","Ratings about Blacks","25 to 49",0.1260736,0.0973548,0.1547924,
"Full controls","Ratings about Blacks","at 50",0.0828104,0.0633727,0.102248,
"Full controls","Ratings about Blacks","51 to 85",0.1395332,0.1258388,0.1532275,
"Full controls","Ratings about Blacks","86 to 99",0.2051881,0.1857102,0.224666,
"Full controls","Ratings about Blacks","at 100",0.2983555,0.2607479,0.3359632,
"Full controls","Ratings about Whites","0 to 24",0.2897018,0.236501,0.3429027,
"Full controls","Ratings about Whites","25 to 49",0.2769997,0.2438245,0.3101748,
"Full controls","Ratings about Whites","at 50",0.1591508,0.1342149,0.1840868,
"Full controls","Ratings about Whites","51 to 85",0.1683675,0.1535977,0.1831373,
"Full controls","Ratings about Whites","86 to 99",0.1099687,0.0934504,0.126487,
"Full controls","Ratings about Whites","at 100",0.1013468,0.0774212,0.1252723)
DATA$GROUP <- factor(DATA$GROUP, levels = unique(DATA$GROUP))
DATA$LEVEL <- factor(DATA$LEVEL, levels = unique(DATA$LEVEL))
DATA.SMALL <- filter(DATA, DATA$CONTROLS == "Small controls")
DATA.FULL <- filter(DATA, DATA$CONTROLS == "Full controls")
theme.z <- theme(
axis.text.x = element_text(size = 15, color = "black", hjust = 0.5 , margin = margin(t = 10,b = 0)),
axis.text.x.top = element_blank(),
axis.text.y = element_text(size = 15, color = "black", hjust = 1 , margin = margin(l = 8,r = 8)),
axis.text.y.right = element_text(size = 15, color = "black", hjust = 0 , margin = margin(l = 8,r = 8)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.background = element_rect(linewidth = 0.5, color = "black", fill = "gray90", linetype = "solid"),
panel.border = element_rect(linewidth = 1.0, color = "black", fill = NA , linetype = "solid"),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
panel.spacing.x = unit(1, "lines"),
panel.spacing.y = unit(1, "lines"),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 12 , hjust = 0 , margin = margin(t = 10)),
plot.margin = unit(c(t = 10,r = 10,b = 10,l = 10),"pt"),
plot.subtitle = element_text(size = 15 , hjust = 0.5, margin = margin(b = 10)),
plot.title = element_text(size = 18 , hjust = 0.5, margin = margin(t = 0,b = 10), face = "bold"),
strip.background = element_rect(linewidth = 1, color = "black", fill = "black"),
strip.text.x = element_text(size = 16, color = "white", face = "bold", margin = margin(t = 7.5,b = 7.5))
)
plot.SMALL <- ggplot(DATA.SMALL, mapping = aes(x = PE, y = LEVEL)) +
facet_wrap(~GROUP, dir = "v", ncol = 1, scales = "free_y") +
geom_rect(data = filter(DATA.SMALL, GROUP == "Ratings about Blacks") , mapping = aes(xmin = DATA.SMALL$PE[DATA.SMALL$GROUP == "Ratings about Blacks" & DATA.SMALL$LEVEL == "0 to 24"], xmax = DATA.SMALL$PE[DATA.SMALL$GROUP == "Ratings about Blacks" & DATA.SMALL$LEVEL == "at 50"] , ymin = -Inf, ymax = Inf), fill = "red3" , color = "black", inherit.aes = FALSE) +
geom_rect(data = filter(DATA.SMALL, GROUP == "Ratings about Blacks") , mapping = aes(xmin = DATA.SMALL$PE[DATA.SMALL$GROUP == "Ratings about Blacks" & DATA.SMALL$LEVEL == "at 50"] , xmax = DATA.SMALL$PE[DATA.SMALL$GROUP == "Ratings about Blacks" & DATA.SMALL$LEVEL == "at 100"], ymin = -Inf, ymax = Inf), fill = "green3" , color = "black", inherit.aes = FALSE) +
geom_rect(data = filter(DATA.SMALL, GROUP == "Ratings about Whites") , mapping = aes(xmin = DATA.SMALL$PE[DATA.SMALL$GROUP == "Ratings about Whites" & DATA.SMALL$LEVEL == "0 to 24"], xmax = DATA.SMALL$PE[DATA.SMALL$GROUP == "Ratings about Whites" & DATA.SMALL$LEVEL == "at 50"] , ymin = -Inf, ymax = Inf), fill = "red3" , color = "black", inherit.aes = FALSE) +
geom_rect(data = filter(DATA.SMALL, GROUP == "Ratings about Whites") , mapping = aes(xmin = DATA.SMALL$PE[DATA.SMALL$GROUP == "Ratings about Whites" & DATA.SMALL$LEVEL == "at 50"] , xmax = DATA.SMALL$PE[DATA.SMALL$GROUP == "Ratings about Whites" & DATA.SMALL$LEVEL == "at 100"], ymin = -Inf, ymax = Inf), fill = "green3" , color = "black", inherit.aes = FALSE) +
geom_errorbarh(mapping = aes(xmin = CILO, xmax = CIHI), height = 0) +
geom_point(color = "black", size = 3.5) +
scale_x_continuous(limits = c(0,1), expand = c(0,0), breaks = 0.5, labels = "Controls for\ndemographics only") +
scale_y_discrete(position = "left") +
geom_text(x = 0.97, y = DATA.SMALL$LEVEL, size = 5, hjust = 1, label = format(round(DATA.SMALL$PE, 2), nsmall = 0)) +
theme.z
plot.FULL <- ggplot(DATA.FULL, mapping = aes(x = PE, y = LEVEL)) +
facet_wrap(~GROUP, dir = "v", ncol = 1, scales = "free_y") +
geom_rect(data = filter(DATA.FULL, GROUP == "Ratings about Blacks") , mapping = aes(xmin = DATA.FULL$PE[DATA.FULL$GROUP == "Ratings about Blacks" & DATA.FULL$LEVEL == "0 to 24"], xmax = DATA.FULL$PE[DATA.FULL$GROUP == "Ratings about Blacks" & DATA.FULL$LEVEL == "at 50"] , ymin = -Inf, ymax = Inf), fill = "red3" , color = "black", inherit.aes = FALSE) +
geom_rect(data = filter(DATA.FULL, GROUP == "Ratings about Blacks") , mapping = aes(xmin = DATA.FULL$PE[DATA.FULL$GROUP == "Ratings about Blacks" & DATA.FULL$LEVEL == "at 50"] , xmax = DATA.FULL$PE[DATA.FULL$GROUP == "Ratings about Blacks" & DATA.FULL$LEVEL == "at 100"], ymin = -Inf, ymax = Inf), fill = "green3" , color = "black", inherit.aes = FALSE) +
geom_rect(data = filter(DATA.FULL, GROUP == "Ratings about Whites") , mapping = aes(xmin = DATA.FULL$PE[DATA.FULL$GROUP == "Ratings about Whites" & DATA.FULL$LEVEL == "0 to 24"], xmax = DATA.FULL$PE[DATA.FULL$GROUP == "Ratings about Whites" & DATA.FULL$LEVEL == "at 50"] , ymin = -Inf, ymax = Inf), fill = "red3" , color = "black", inherit.aes = FALSE) +
geom_rect(data = filter(DATA.FULL, GROUP == "Ratings about Whites") , mapping = aes(xmin = DATA.FULL$PE[DATA.FULL$GROUP == "Ratings about Whites" & DATA.FULL$LEVEL == "at 50"] , xmax = DATA.FULL$PE[DATA.FULL$GROUP == "Ratings about Whites" & DATA.FULL$LEVEL == "at 100"], ymin = -Inf, ymax = Inf), fill = "green3" , color = "black", inherit.aes = FALSE) +
geom_errorbarh(mapping = aes(xmin = CILO, xmax = CIHI), height = 0) +
geom_point(color = "black", size = 3.5) +
scale_x_continuous(limits = c(0,1), expand = c(0,0), breaks = 0.5, labels = "Controls for demographics,\npartisanship, and ideology") +
scale_y_discrete(position = "right") +
geom_text(x = 0.97, y = DATA.FULL$LEVEL, size = 5, hjust = 1, label = format(round(DATA.FULL$PE, 2), nFULL = 0)) +
theme.z
plot.SMALL + plot.FULL +
plot_annotation(title = "Support for Reparations") & theme(plot.title = element_text(face = "bold", size = 18, hjust = 0.5))
library(patchwork)
library(tidyverse)
DATA <- tribble(
~GENDERFAVOR,~GROUP,~PE,~CILO,~CIHI,
"Cold only to women","U.S. residents",0.0385036,0.0340647,0.0434949,
"Cold only to women","Believed Blasey Ford",0.1641699,0.1020244,0.2263155,
"Residual colder to women","U.S. residents",0.1580191,0.1496165,0.166801,
"Residual colder to women","Believed Blasey Ford",0.1979061,0.16163,0.2341823,
"Rated men equal to women","U.S. residents",0.1869231,0.1777329,0.1964749,
"Rated men equal to women","Believed Blasey Ford",0.308813,0.2644603,0.3531658,
"Did not rate men and/or women","U.S. residents",0.1068526,0.097831,0.1165985,
"Did not rate men and/or women","Believed Blasey Ford",0.311967,0.2394761,0.3844578,
"Residual colder to men","U.S. residents",0.3991769,0.3872212,0.4112541,
"Residual colder to men","Believed Blasey Ford",0.3985176,0.3594298,0.4376055,
"Cold only to men","U.S. residents",0.1105247,0.1030948,0.1184195,
"Cold only to men","Believed Blasey Ford",0.5188692,0.4589192,0.5788192)
theme.z <- theme(
axis.text.x = element_text(color = "black", size = 15, margin = margin(t = 5, b = 5)),
axis.text.y = element_text(color = "black", size = 15, margin = margin(l = 0, r = 0)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
legend.position = "none",
panel.background = element_blank(),
panel.border = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.margin = unit(c(t = 10,r = 0,b = 10,l = 0), "pt"))
DATA.DIST <- filter(DATA, GROUP == "U.S. residents")
DATA.DIST$GENDERFAVOR <- factor(DATA.DIST$GENDERFAVOR, levels = unique(DATA.DIST$GENDERFAVOR))
UCM <- DATA$PE[DATA$GROUP == "U.S. residents" & DATA$GENDERFAVOR == "Cold only to men"]
URM <- DATA$PE[DATA$GROUP == "U.S. residents" & DATA$GENDERFAVOR == "Residual colder to men"]
UDN <- DATA$PE[DATA$GROUP == "U.S. residents" & DATA$GENDERFAVOR == "Did not rate men and/or women"]
UEQ <- DATA$PE[DATA$GROUP == "U.S. residents" & DATA$GENDERFAVOR == "Rated men equal to women"]
URW <- DATA$PE[DATA$GROUP == "U.S. residents" & DATA$GENDERFAVOR == "Residual colder to women"]
UCW <- DATA$PE[DATA$GROUP == "U.S. residents" & DATA$GENDERFAVOR == "Cold only to women"]
BREAKS <- c(UCM/2, UCM+URM/2, UCM+URM+UDN/2, UCM+URM+UDN+UEQ/2, UCM+URM+UDN+UEQ+URW/2, UCM+URM+UDN+UEQ+URW+UCW/2)
p1 <- ggplot(DATA.DIST, mapping = aes(y = 100*PE, x = GROUP, fill = GENDERFAVOR)) +
geom_col(color = "black", linewidth = 1.1, width = 1) +
scale_fill_manual(values=c("Cold only to men"="lightskyblue3", "Residual colder to men"="powderblue", "Did not rate men and/or women"="gray90", "Rated men equal to women"="white", "Residual colder to women"="lightpink1", "Cold only to women"="lightpink3"), name="Category") +
scale_y_continuous(limits = c(0,100.01), breaks = 100*BREAKS, labels=unique(rev(DATA$GENDERFAVOR))) +
scale_x_discrete(position="top") +
coord_cartesian(clip="off") +
theme.z
DATA.KF <- filter(DATA, GROUP == "Believed Blasey Ford")
RCM <- DATA$PE[DATA$GROUP == "Republicans" & DATA$GENDERFAVOR == "Cold only to men"]
RRM <- DATA$PE[DATA$GROUP == "Republicans" & DATA$GENDERFAVOR == "Residual colder to men"]
RDN <- DATA$PE[DATA$GROUP == "Republicans" & DATA$GENDERFAVOR == "Did not rate men and/or women"]
REQ <- DATA$PE[DATA$GROUP == "Republicans" & DATA$GENDERFAVOR == "Rated men equal to women"]
RRW <- DATA$PE[DATA$GROUP == "Republicans" & DATA$GENDERFAVOR == "Residual colder to women"]
RCW <- DATA$PE[DATA$GROUP == "Republicans" & DATA$GENDERFAVOR == "Cold only to women"]
p2 <- ggplot(data=DATA.KF, mapping = aes(x = PE, y = rev(BREAKS))) +
geom_segment(mapping = aes(x = 0, y = rev(BREAKS), xend=1, yend=rev(BREAKS)), color = "gray80") +
geom_point(color = "black", size = 5) +
geom_errorbarh(mapping = aes(xmin=CILO, xmax = CIHI), size = 1.25, height = 0) +
scale_x_continuous(expand=c(0,0), limits = c(0,1), breaks = c(0.5), labels=c("Predicted probability of believing\nBlasey Ford, net of controls"), position="top") +
scale_y_continuous(limits = c(0,1)) +
theme.z +
theme(
axis.text.y = element_blank(),
plot.margin = unit(c(t = 10, r = 15, b = 10, l = 0), "pt"))
p1 + p2 + plot_layout(ncol = 2, widths = c(1,1.5))
library(patchwork)
library(tidyverse)
DATA <- read_csv("Grid.csv")
print(DATA, n = Inf)
## # A tibble: 24 × 10
## FACET THERMO OUTCOME ...4 PE ...6 ...7 ...8 CILO CIHI
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 No controls Text … Outcom… 1 0.415 0.219 1.9 0.058 0.112 0.718
## 2 No controls Text … Outcom… 2 0.414 0.0615 6.74 0 0.329 0.499
## 3 No controls Text … Outcom… 3 0.540 0.0622 8.68 0 0.453 0.626
## 4 No controls Text … Outcom… 1 0.0814 0.0315 2.58 0.01 0.0377 0.125
## 5 No controls Text … Outcom… 2 0.500 0.0465 10.8 0 0.436 0.565
## 6 No controls Text … Outcom… 3 0.419 0.0455 9.2 0 0.355 0.482
## 7 No controls Text … Outcom… 1 0.140 0.0180 7.77 0 0.115 0.165
## 8 No controls Text … Outcom… 2 0.0743 0.0447 1.66 0.097 0.0124 0.136
## 9 No controls Text … Outcom… 3 0.481 0.167 2.89 0.004 0.250 0.712
## 10 No controls Text … Outcom… 1 0.163 0.0177 9.24 0 0.139 0.188
## 11 No controls Text … Outcom… 2 0.131 0.0692 1.89 0.059 0.0347 0.226
## 12 No controls Text … Outcom… 3 0.513 0.168 3.06 0.002 0.281 0.746
## 13 Demographic con… Text … Outcom… 1 0.0666 0.0156 4.27 0 0.0450 0.0883
## 14 Demographic con… Text … Outcom… 2 0.583 0.0278 21.0 0 0.545 0.622
## 15 Demographic con… Text … Outcom… 3 0.350 0.0265 13.2 0 0.313 0.387
## 16 Demographic con… Text … Outcom… 1 0.548 0.0760 7.21 0 0.443 0.654
## 17 Demographic con… Text … Outcom… 2 0.531 0.0422 12.6 0 0.472 0.589
## 18 Demographic con… Text … Outcom… 3 0.412 0.0413 9.98 0 0.355 0.469
## 19 Demographic con… Text … Outcom… 1 0.150 0.0761 1.97 0.049 0.0446 0.255
## 20 Demographic con… Text … Outcom… 2 0.199 0.0950 2.1 0.036 0.0674 0.331
## 21 Demographic con… Text … Outcom… 3 0.106 0.0641 1.65 0.098 0.0172 0.195
## 22 Demographic con… Text … Outcom… 1 0.147 0.0236 6.24 0 0.114 0.180
## 23 Demographic con… Text … Outcom… 2 0.106 0.0641 1.65 0.098 0.0172 0.195
## 24 Demographic con… Text … Outcom… 3 0.199 0.0950 2.1 0.036 0.0674 0.331
theme.z <- theme(
axis.text.x = element_blank(),
axis.text.x.top = element_blank(),
axis.text.y = element_text(size = 15, color = "black", hjust = 1 , margin = margin(l = 8, r = 8)),
axis.text.y.right = element_text(size = 15, color = "black", hjust = 0 , margin = margin(l = 8, r = 8)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_text(size = 15, color = "black", hjust = 0.5, margin = margin(t = 8,b = 0)),
axis.title.y = element_blank(),
legend.position = "none",
panel.background = element_rect(linewidth = 0.5, color = "black", fill = "gray90", linetype = "solid"),
panel.border = element_rect(linewidth = 1.0, color = "black", fill = NA , linetype = "solid"),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
panel.spacing.x = unit(1, "lines"),
panel.spacing.y = unit(1, "lines"),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 12 , hjust = 0 , margin = margin(t = 10)),
plot.margin = unit(c(t = 10,r = 0,b = 10,l = 0),"pt"),
plot.subtitle = element_text(size = 15 , hjust = 0.5, margin = margin(b = 10)),
plot.title = element_text(size = 17 , hjust = 0.5, margin = margin(t = 0,b = 10), face = "bold"),
strip.background = element_rect(linewidth = 1.0, color = "black", fill = "black"),
strip.text.x = element_text(size = 18, color = "white", face = "bold", margin = margin(t = 7.5, b = 7.5, l = 25, r = 25)),
strip.text.y = element_text(size = 18, color = "white", face = "bold", margin = margin(t = 7.5, b = 7.5, l = 7.5, r = 7.5))
)
DATA$FACET <- factor(DATA$FACET , levels = unique(DATA$FACET))
DATA$OUTCOME <- factor(DATA$OUTCOME, levels = unique(DATA$OUTCOME))
DATA$THERMO <- factor(DATA$THERMO , levels = rev(unique(DATA$THERMO)))
DATA.NEGNC <- filter(DATA, OUTCOME == "Outcome 1" & DATA$FACET == "No controls")
DATA.POSNC <- filter(DATA, OUTCOME == "Outcome 2" & DATA$FACET == "No controls")
DATA.NEGPC <- filter(DATA, OUTCOME == "Outcome 1" & DATA$FACET == "Demographic controls")
DATA.POSPC <- filter(DATA, OUTCOME == "Outcome 2" & DATA$FACET == "Demographic controls")
ggplot(DATA, mapping = aes(PE, THERMO)) +
facet_grid(FACET ~ OUTCOME, switch="y", space = "free_y", scales = "free_y", labeller = labeller(FACET = label_wrap_gen(width = 15), OUTCOME = label_wrap_gen(width = 15))) +
geom_rect(data = DATA.NEGNC, mapping = aes(xmin = min(DATA.NEGNC$PE), xmax = max(DATA.NEGNC$PE), ymin = -Inf, ymax = Inf), color = "black", fill = "lightsteelblue3", inherit.aes = FALSE) +
geom_rect(data = DATA.POSNC, mapping = aes(xmin = min(DATA.POSNC$PE), xmax = max(DATA.POSNC$PE), ymin = -Inf, ymax = Inf), color = "black", fill = "lightsteelblue3", inherit.aes = FALSE) +
geom_rect(data = DATA.NEGPC, mapping = aes(xmin = min(DATA.NEGPC$PE), xmax = max(DATA.NEGPC$PE), ymin = -Inf, ymax = Inf), color = "black", fill = "lightsteelblue3", inherit.aes = FALSE) +
geom_rect(data = DATA.POSPC, mapping = aes(xmin = min(DATA.POSPC$PE), xmax = max(DATA.POSPC$PE), ymin = -Inf, ymax = Inf), color = "black", fill = "lightsteelblue3", inherit.aes = FALSE) +
geom_errorbarh(mapping = aes(xmin = CILO, xmax = CIHI), height = 0, size = 0.5) +
geom_point(size = 4) +
geom_text(x = 0.95, y = DATA$THERMO, size = 5, hjust = 1, label = format(round(DATA$PE, 2), nsmall = 2)) +
scale_x_continuous(breaks = seq(0,1), limits = c(0,1), expand = c(0,0)) +
scale_y_discrete(position = "right") +
labs(x = "Predicted probability") +
theme.z
library(patchwork)
library(tidyverse)
theme.z <- theme(
axis.text.x = element_text(size = 15, color = "black", hjust = 0.5, margin = margin(t = 8, b = 0)),
axis.text.x.top = element_text(size = 15, color = "black", hjust = 0.5, margin = margin(t = 8, b = 0)),
axis.text.y = element_text(size = 15, color = "black", hjust = 1 , margin = margin(l = 8, r = 8)),
axis.text.y.right = element_text(size = 15, color = "black", hjust = 0 , margin = margin(l = 8, r = 8)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
legend.position = "none",
panel.background = element_blank(),
panel.border = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
panel.spacing.x = unit(2, "lines"),
panel.spacing.y = unit(1, "lines"),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 12 , hjust = 0 , margin = margin(t = 10)),
plot.margin = unit(c(t = 10,r = 5,b = 10,l = 5),"pt"),
plot.subtitle = element_text(size = 15 , hjust = 0.5, margin = margin(b = 10)),
plot.title = element_text(size = 17 , hjust = 0.5, margin = margin(t = 0, b = 10), face = "bold"),
)
DATA <- read_csv("Ticks.csv")
print(DATA, n = Inf)
## # A tibble: 35 × 8
## SECTION LABELY GROUP ...4 PE ...6 CILO CIHI
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Rated immigrants 0 to 25 Rated 0 t… Rati… 0 0.0841 0.00433 0.0783 0.0903
## 2 Rated immigrants 26 to 49 Rated 26 … Rati… 1 0.104 0.00466 0.0973 0.110
## 3 Rated immigrants at 50 Rated at … Rati… 2 0.0899 0.00420 0.0843 0.0959
## 4 Did not rate immigrants Did not r… Rati… 3 0.0556 0.00384 0.0505 0.0612
## 5 Rated immigrants 51 to 75 Rated 51 … Rati… 4 0.258 0.00641 0.249 0.267
## 6 Rated immigrants 76 to 99 Rated 76 … Rati… 5 0.331 0.00679 0.322 0.341
## 7 Rated immigrants at 100 Rated at … Rati… 6 0.0776 0.00400 0.0722 0.0833
## 8 Rated Whites 0 to 25 Rated 0 t… Rati… 0 0.0550 0.00371 0.0501 0.0604
## 9 Rated Whites 26 to 49 Rated 26 … Rati… 1 0.108 0.00481 0.101 0.115
## 10 Rated Whites at 50 Rated at … Rati… 2 0.107 0.00461 0.101 0.114
## 11 Did not rate Whites Did not r… Rati… 3 0.0390 0.00333 0.0346 0.0439
## 12 Rated Whites 51 to 75 Rated 51 … Rati… 4 0.251 0.00642 0.242 0.260
## 13 Rated Whites 76 to 99 Rated 76 … Rati… 5 0.361 0.00690 0.352 0.371
## 14 Rated Whites at 100 Rated at … Rati… 6 0.0788 0.00396 0.0735 0.0845
## 15 Rated Blacks 0 to 25 Rated 0 t… Rati… 0 0.0562 0.00365 0.0514 0.0615
## 16 Rated Blacks 26 to 49 Rated 26 … Rati… 1 0.0808 0.00421 0.0751 0.0868
## 17 Rated Blacks at 50 Rated at … Rati… 2 0.0846 0.00408 0.0792 0.0905
## 18 Did not rate Blacks Did not r… Rati… 3 0.0383 0.00320 0.0341 0.0430
## 19 Rated Blacks 51 to 75 Rated 51 … Rati… 4 0.239 0.00629 0.230 0.247
## 20 Rated Blacks 76 to 99 Rated 76 … Rati… 5 0.386 0.00710 0.376 0.396
## 21 Rated Blacks at 100 Rated at … Rati… 6 0.115 0.00471 0.109 0.122
## 22 Rated Hispanics 0 to 25 Rated 0 t… Rati… 0 0.0428 0.00310 0.0387 0.0473
## 23 Rated Hispanics 26 to 49 Rated 26 … Rati… 1 0.0755 0.00403 0.0701 0.0812
## 24 Rated Hispanics at 50 Rated at … Rati… 2 0.0859 0.00412 0.0804 0.0918
## 25 Did not rate Hispanics Did not r… Rati… 3 0.0514 0.00369 0.0465 0.0567
## 26 Rated Hispanics 51 to 75 Rated 51 … Rati… 4 0.254 0.00643 0.245 0.263
## 27 Rated Hispanics 76 to 99 Rated 76 … Rati… 5 0.384 0.00709 0.374 0.394
## 28 Rated Hispanics at 100 Rated at … Rati… 6 0.107 0.00460 0.100 0.113
## 29 Rated Asians 0 to 25 Rated 0 t… Rati… 0 0.0403 0.00332 0.0360 0.0452
## 30 Rated Asians 26 to 49 Rated 26 … Rati… 1 0.0738 0.00420 0.0682 0.0799
## 31 Rated Asians at 50 Rated at … Rati… 2 0.0903 0.00417 0.0846 0.0962
## 32 Did not rate Asians Did not r… Rati… 3 0.0594 0.00391 0.0542 0.0651
## 33 Rated Asians 51 to 75 Rated 51 … Rati… 4 0.245 0.00643 0.236 0.254
## 34 Rated Asians 76 to 99 Rated 76 … Rati… 5 0.391 0.00705 0.382 0.401
## 35 Rated Asians at 100 Rated at … Rati… 6 0.0996 0.00435 0.0937 0.106
DATA$GROUP <- factor(DATA$GROUP , levels = unique(DATA$GROUP))
DATA$SECTION <- factor(DATA$SECTION, levels = rev(unique(DATA$SECTION)))
LABELS <- c("Ratings about immigrants" = "Ratings\nabout\nimmigrants", "Ratings about Whites" = "Ratings\nabout\nWhites", "Ratings about Blacks" = "Ratings\nabout\nBlacks", "Ratings about Hispanics" = "Ratings\nabout\nHispanics", "Ratings about Asians" = "Ratings\nabout\nAsians")
ggplot(DATA, aes(fill = SECTION, y = 100*PE, x = GROUP)) +
geom_col(color = "black", linewidth = 1, width = 1) +
geom_rect(aes(xmin = 0.5, xmax = 5.5, ymin = 0, ymax = 100), fill = NA, col = "black", linewidth = 1.5) +
scale_fill_manual(values = rep.int(c("green3", "green1", "lightgreen", "white", "gray90", "pink2", "red3"), 8)) +
scale_y_continuous(limits = c(0,100.1), position = "left", breaks = c(4.2,13.6,23.3,30.5,46.2,75.7,96.1), label = unique(DATA$LABELY), expand=c(0,0), sec.axis = sec_axis(~.,breaks = seq(0,100,10), label = c("\u2014",rep.int("\u2013",4),"\u2014",rep.int("\u2013",4),"\u2014"))) +
scale_x_discrete(labels=LABELS, expand = c(0,0)) +
theme.z +
theme(plot.margin = unit(c(t = 10, r = 5, b = 15, l = 5), "pt"))
library(patchwork)
library(tidyverse)
DATA <- read_csv("Array.csv")
print(DATA, n = Inf)
## # A tibble: 8 × 7
## GROUP PE ...3 ...4 ...5 CILO CIHI
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Rated immigrants cold and at least 25 u… 0.137 0.0554 2.47 0.014 0.0600 0.214
## 2 Rated immigrants cold and at least 5 un… 0.301 0.0594 5.07 0 0.219 0.383
## 3 Rated immigrants cold and colder than e… 0.294 0.0537 5.48 0 0.220 0.369
## 4 Rated immigrants colder than each of WB… 0.370 0.0404 9.16 0 0.314 0.426
## 5 Rated immigrants equal to each of WBHA 0.514 0.0662 7.77 0 0.422 0.605
## 6 Rated immigrants within 5 or fewer unit… 0.552 0.0432 12.8 0 0.492 0.611
## 7 Rated immigrants warm and at least 5 un… 0.768 0.0780 9.84 0 0.660 0.876
## 8 Rated immigrants at 100 but did not rat… 0.763 0.0887 8.6 0 0.640 0.886
theme.z <- theme(
axis.text.x = element_blank(),
axis.text.x.top = element_text(size = 15, color = "black", hjust = 1 , margin = margin(t = 8,b = 0)),
axis.text.y = element_text(size = 15, color = "black", hjust = 1 , margin = margin(l = 8,r = 8)),
axis.text.y.right = element_text(size = 15, color = "black", hjust = 0 , margin = margin(l = 8,r = 8)),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_text(size = 15, color = "black", hjust = 0.5, margin = margin(t = 8,b = 0)),
axis.title.y = element_blank(),
legend.position = "none",
panel.background = element_rect(linewidth = 0.5, color = "black", fill = "gray90", linetype = "solid"),
panel.border = element_rect(linewidth = 1.2, color = "black", fill = NA , linetype = "solid"),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
panel.spacing.x = unit(1, "lines"),
panel.spacing.y = unit(1, "lines"),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 12 , hjust = 0 , margin = margin(t = 10)),
plot.margin = unit(c(t = 10,r = 40,b = 10,l = 0),"pt"),
plot.subtitle = element_text(size = 15 , hjust = 0.5, margin = margin(b = 10)),
plot.title = element_text(size = 17 , hjust = 0.5, margin = margin(t = 0,b = 10), face = "bold"),
strip.background = element_rect(color = "black", fill = "black"),
strip.text.x = element_text(size = 18, color = "white", face = "bold", margin = margin(t = 7.5, b = 7.5))
)
DATA$GROUP <- factor(DATA$GROUP, levels = unique(rev(DATA$GROUP)))
ggplot(DATA, aes(PE, GROUP)) +
geom_rect(data = DATA, aes(xmin = min(DATA$PE), xmax = DATA$PE[DATA$GROUP == "Rated immigrants equal to each of WBHA"], ymin = -Inf, ymax = Inf), color = "black", fill = "red3" , inherit.aes = FALSE) +
geom_rect(data = DATA, aes(xmax = max(DATA$PE), xmin = DATA$PE[DATA$GROUP == "Rated immigrants within 5 or fewer units of each of WBHA"], ymin = -Inf, ymax = Inf), color = "black", fill = "green3", inherit.aes = FALSE) +
geom_errorbarh(aes(xmin = CILO, xmax = CIHI), height = 0, size = 0.5) +
geom_point(size = 4) +
geom_text(x = 1.05, y = DATA$GROUP, size = 5, hjust = 0, label = format(round(DATA$PE, 2), nsmall = 2)) +
coord_cartesian(clip = "off") +
scale_x_continuous(limits = c(0,1), expand = c(0,0)) +
labs(x = "Predicted probability of\nan intended vote\nfor Joe Biden\nover Donald Trump") +
theme.z
library(ggdag)
library(patchwork)
library(tidyverse)
TOL <- 0.25
theme.z <- theme(
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.title.y.right = element_blank(),
panel.background = element_rect(linewidth = 0.5, color = "black", fill = "gray95", linetype = "solid"),
panel.border = element_rect(linewidth = 1.0, color = "black", fill = NA , linetype = "solid"),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 14, hjust = 0 , margin = margin(t = 10)),
plot.margin = unit(c(t = 10,r = 10,b = 10,l = 10),"pt"),
plot.subtitle = element_text(size = 15, hjust = 0.5, margin = margin(t = 0,b = 8)),
plot.title = element_text(size = 20, hjust = 0.5, face = "bold", margin = margin(t = 0,b = 12)))
DAG.COORDS <- list(
x = c(X = 0 , Z = 0.5, Y = 1),
y = c(X = 0 , Z = 1 , Y = 0))
CAPTION.CNF <- str_wrap("Control for Z to help isolate the effect of the \"treatment\" X on Y. Controlling for Z helps get all-else-equal before the \"treatment\" X and the outcome Y.", width = 42)
CAPTION.COL <- str_wrap("Do not control for Z. Controlling for Z would help get all-else-equal *after* the \"treatment\" X and the outcome Y, but there's no need to do that.", width = 42)
CAPTION.MED <- str_wrap("To estimate the total effect of X on Y, do not control for Z. Control for Z to isolate the effect of X on Y that does not run through Z.", width = 42)
CNF <- ggdag(dagify(
Y ~ X,
X ~ Z,
Y ~ Z,
coords=DAG.COORDS
)) +
geom_dag_point(shape = 21, color = "black", fill = "slategray3", stroke = 1.2) +
geom_dag_edges(edge_color = "black", edge_width = 1) +
geom_dag_text(color = "black") +
scale_x_continuous(limits = c(0 - TOL, 1 + TOL)) +
scale_y_continuous(limits = c(0 - TOL, 1 + TOL)) +
labs(title = "Confounder", caption = CAPTION.CNF) + theme.z
COL <- ggdag(dagify(
Y ~ X,
Z ~ X,
Z ~ Y,
coords=DAG.COORDS
)) +
geom_dag_point(shape = 21, color = "black", fill = "slategray3", stroke = 1.2) +
geom_dag_edges(edge_color = "black", edge_width = 1) +
geom_dag_text(color = "black") +
scale_x_continuous(limits = c(0 - TOL, 1 + TOL)) +
scale_y_continuous(limits = c(0 - TOL, 1 + TOL)) +
labs(title = "Collider", caption = CAPTION.COL) + theme.z
MED <- ggdag(dagify(
Y ~ X,
Z ~ X,
Y ~ Z,
coords=DAG.COORDS
)) +
geom_dag_point(shape = 21, color = "black", fill = "slategray3", stroke = 1.2) +
geom_dag_edges(edge_color = "black", edge_width = 1) +
geom_dag_text(color = "black") +
scale_x_continuous(limits = c(0 - TOL, 1 + TOL)) +
scale_y_continuous(limits = c(0 - TOL, 1 + TOL)) +
labs(title = "Mediator", caption = CAPTION.MED) + theme.z
CNF + COL + plot_layout(nrow=1)
library(tidyverse)
theme.z <- theme(
axis.text.x = element_text(color = "black", size = 15),
axis.text.y = element_text(color = "black", size = 15),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_text(color = "black", size = 15),
axis.title.y = element_text(color = "black", size = 15),
legend.position = "none",
panel.background = element_rect(fill = "gray90"),
panel.border = element_rect(color = "black", fill = NA, size = 1.1),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.caption = element_text(size = 12 , hjust = 0, margin = margin(t = 10)),
plot.margin = unit(c(0.5, 0.5, 0.5, 0.5), "cm"),
plot.title = element_text(face = "bold", size = 18, hjust = 0.5,margin = margin(b = 10)))
SAMPLE <- seq(10, 600, 1)
QT <- qt(0.975, SAMPLE - 1)
DATA <- data.frame(SAMPLE, QT)
ggplot(data=DATA, aes(x = SAMPLE,y = QT)) +
geom_rect(data = DATA, aes(xmin = -Inf, xmax = Inf, ymin = 1.95, ymax = 1.96), fill = "gray85") +
geom_rect(data = DATA, aes(xmin = -Inf, xmax = Inf, ymin = 1.97, ymax = 1.98), fill = "gray85") +
geom_rect(data = DATA, aes(xmin = -Inf, xmax = Inf, ymin = 1.99, ymax = 2.00), fill = "gray85") +
geom_rect(data = DATA, aes(xmin = -Inf, xmax = Inf, ymin = 2.01, ymax = 2.02), fill = "gray85") +
geom_rect(data = DATA, aes(xmin = -Inf, xmax = Inf, ymin = 2.03, ymax = 2.04), fill = "gray85") +
geom_rect(data = DATA, aes(xmin = -Inf, xmax = Inf, ymin = 2.05, ymax = 2.06), fill = "gray85") +
geom_rect(data = DATA, aes(xmin = -Inf, xmax = Inf, ymin = 2.07, ymax = 2.08), fill = "gray85") +
geom_rect(data = DATA, aes(xmin = -Inf, xmax = Inf, ymin = 2.09, ymax = 2.10), fill = "gray85") +
geom_point(size = 1) +
scale_x_continuous(limits = c(0,600), expand=c(0,0), breaks = seq(0,600,50)) +
scale_y_continuous(limits = c(1.95,2.1), breaks = seq(1.95,2.1,0.01), sec.axis = dup_axis()) +
labs(y = "Multiplier", x = "Sample size", title = "Multiplier in a formula for\nthe margin of error for a measurement\nfrom a random sample, at the 95% confidence level") +
theme.z
library(patchwork)
library(tidyverse)
theme.z <- theme(
axis.text.x = element_text(size = 15, color = "black", margin = margin(t = 8, b = 8)),
axis.text.y = element_blank(),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.background = element_rect(linewidth = 0.5, color = "black", fill = "gray90", linetype = "solid"),
panel.border = element_rect(linewidth = 1.0, color = "black", fill = NA , linetype = "solid"),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
panel.spacing.x = unit(2, "lines"),
panel.spacing.y = unit(0, "lines"),
plot.background = element_rect(fill = "white"),
plot.caption = element_text(size = 10, hjust = 0, margin = margin(t = 8)),
plot.margin = unit(c(0.15,0.5,0.15,0.5), "cm"),
plot.subtitle = element_text(size = 15, hjust = 0.5, margin = margin(b = 7)),
plot.title = element_text(size = 20, hjust = 0.5, face = "bold", margin = margin(t = 0, b = 12)),
strip.background = element_rect(linewidth = 1, color = "black", fill = "black"),
strip.text.x = element_text(size = 17, color = "white", face = "bold", margin = margin(t = 7.5, b = 7.5))
)
DATA <- tribble(
~FACET,~X, ~Y,
"Standard deviation of 2.12", -5,1,
"Standard deviation of 2.12", -2,1)
ggplot(data = DATA, aes(x = X, y = Y)) +
facet_wrap(~FACET, ncol = 1, dir = "v", scales = "free") +
geom_curve(data = filter(DATA, FACET == "Standard deviation of 1.41"), aes(x = -5, y = 1, xend = -3.5, yend = 1), size = 1, curvature = -0.30, color = "slategray3") +
geom_curve(data = filter(DATA, FACET == "Standard deviation of 1.41"), aes(x = -3.5, y = 1, xend = -2, yend = 1), size = 1, curvature = -0.30, color = "slategray3") +
geom_point(size = 3.5) +
scale_y_continuous(limits = c(0.5,2.5)) +
scale_x_continuous(breaks = seq(-5,-2,1), limits = c(-5.2,-1.8), labels = scales::number_format(accuracy = 1)) +
theme.z