【R】ggpubr
2021年5月30日
1. はじめに
ggpubrは、ggplotでpublication-readyなグラフを出力するパッケージです。
2. インストール
CRANからインストールできます。
install.packages("ggpubr")
3. つかってみる
まずは、例にあるもので確認します。
library(ggpubr)
set.seed(1234)
wdata = data.frame(
sex = factor(rep(c("F", "M"), each=200)),
weight = c(rnorm(200, 55), rnorm(200, 58)))
head(wdata, 4)
sex weight
1 F 53.79293
2 F 55.27743
3 F 56.08444
4 F 52.65430
ggdensity(wdata, x = "weight",
add = "mean", rug = TRUE,
color = "sex", fill = "sex",
palette = c("#00AFBB", "#E7B800"))

gghistogram(wdata, x = "weight",
add = "mean", rug = TRUE,
color = "sex", fill = "sex",
palette = c("#00AFBB", "#E7B800"))

4. さいごに
確かにこれはお手軽!