Last active
January 4, 2016 22:56
-
-
Save dmarcelinobr/b2cc9f3964d7608f29b5 to your computer and use it in GitHub Desktop.
height of president divided by height of most successful opponent. Data from Stulp et al. 2013's paper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
height_ratio <- c(0.924324324, 1.081871345, 1, 0.971098266, 1.029761905, | |
0.935135135, 0.994252874, 0.908163265, 1.045714286, 1.18404908, | |
1.115606936, 0.971910112, 0.97752809, 0.978609626, 1, | |
0.933333333, 1.071428571, 0.944444444, 0.944444444, 1.017142857, | |
1.011111111, 1.011235955, 1.011235955, 1.089285714, 0.988888889, | |
1.011111111, 1.032967033, 1.044444444, 1, 1.086705202, | |
1.011560694, 1.005617978, 1.005617978, 1.005494505, 1.072222222, | |
1.011111111, 0.983783784, 0.967213115, 1.04519774, 1.027777778, | |
1.086705202, 1, 1.005347594, 0.983783784, 0.943005181, 1.057142857) | |
vote_support <- c(0.427780852, 0.56148981, 0.597141922, 0.581254292, 0.530344067, | |
0.507425996, 0.526679292, 0.536690951, 0.577825976, 0.573225387, | |
0.550410082, 0.559380032, 0.484823958, 0.500466176, 0.502934212, | |
0.49569636, 0.516904414, 0.522050547, 0.531494442, 0.60014892, | |
0.545079801, 0.604274986, 0.51635906, 0.63850958, 0.652184407, | |
0.587920412, 0.5914898, 0.624614752, 0.550040193, 0.537771958, | |
0.523673642, 0.554517134, 0.577511576, 0.500856251, 0.613444534, | |
0.504063153, 0.617883695, 0.51049949, 0.553073235, 0.59166415, | |
0.538982024, 0.53455133, 0.547304058, 0.497350649, 0.512424242, | |
0.536914796) | |
# Make a data.frame | |
Presidents = data.frame(cbind(height_ratio, vote_support)) | |
# Make the plot | |
heightPlot <- function() { | |
library(ggplot2) | |
library(SciencesPo) | |
fit=lm(vote_support~height_ratio,data=Presidents) | |
mylabel=lm2eqn("Presidents","height_ratio","vote_support") | |
ggplot(Presidents, aes(y=vote_support, x=height_ratio)) + | |
geom_smooth(method=lm, colour="red", fill="gold")+ | |
geom_point(size=5, alpha=.7) + | |
annotate(geom='text',x=1.1,y=.67,size=7,label=mylabel,family='Times',fontface='italic')+ | |
xlim(.9,1.2) + ylim(.40, .70)+ | |
xlab("Presidential Height Ratio") + | |
ylab("Relative Support for President") + | |
theme_pub() | |
} | |
heightPlot() |
The mentioned function is indeed part of the package SciencesPo
, but only available if installed from GitHub repo.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice plot. Not reproducible though, as lm2eq and theme_pub() aren't defined in the code or as part of R either of the libraries defined.