FALSE ── Attaching packages ──────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
FALSE ✓ ggplot2 3.3.2     ✓ purrr   0.3.4
FALSE ✓ tibble  3.0.1     ✓ dplyr   1.0.0
FALSE ✓ tidyr   1.1.0     ✓ stringr 1.4.0
FALSE ✓ readr   1.3.1     ✓ forcats 0.5.0
FALSE ── Conflicts ─────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
FALSE x dplyr::filter() masks stats::filter()
FALSE x dplyr::lag()    masks stats::lag()
FALSE 
FALSE Attaching package: 'magrittr'
FALSE The following object is masked from 'package:purrr':
FALSE 
FALSE     set_names
FALSE The following object is masked from 'package:tidyr':
FALSE 
FALSE     extract
FALSE 
FALSE Attaching package: 'table1'
FALSE The following objects are masked from 'package:base':
FALSE 
FALSE     units, units<-
FALSE Loading required package: SNPassoc
FALSE Loading required package: haplo.stats
FALSE Loading required package: survival
FALSE Loading required package: mvtnorm
FALSE Loading required package: parallel
FALSE Registered S3 method overwritten by 'SNPassoc':
FALSE   method            from       
FALSE   summary.haplo.glm haplo.stats

Reading data

# https://awesomejelly.com/how-some-us-presidents-rank-according-to-iq-t2
iq = read_excel("~/Dropbox/Bai giang online/Datasets/IQ of US Presidents.xlsx")

# https://awesomejelly.com/u-s-presidents-ranked-according-to-net-worth-the-wealthiest-might-surprise-you-t2
inc = read_excel("~/Dropbox/Bai giang online/Datasets/Income net of US Presidents.xlsx")

Plotting data

ggplot(data=iq, aes(x=reorder(Name, IQ), y=IQ, fill=Name)) + geom_bar(stat="identity") + geom_hline(yintercept=mean(iq$IQ), linetype="dashed") + coord_flip() + theme(legend.position="none") + labs(x="", y="IQ")

ggplot(data=inc, aes(x=reorder(Name, Income1), y=log10(Income1), fill=Name)) + geom_bar(stat="identity") + geom_text(aes(label=Income), size=2.5, hjust=1.5, vjust=0.5, col="black") + geom_hline(yintercept=median(log10(inc$Income1)), linetype="dashed") + coord_flip() + theme(legend.position="none") + labs(x="", y="Income (log10(million USD))")