症例数を可視化するには横棒グラフが便利
CSVは↓の感じ
今回は脳外科の急患の内訳を使う
〜 # bar plot library(ggplot2) library(ggsci) dat <- read.csv("/Users/Desktop/Book1.csv",header=TRUE) attach(dat) p <- ggplot(dat,aes(x = reorder(x = disease, X = n, FUN = mean), y = n), fill = disease) p <- p + geom_bar(stat = "identity") #横棒へ p <- p + coord_flip() #凡例消す p <- p + theme(legend.position = "none") #titleなど余分なものをけす p <- p + theme(axis.title.x = element_blank(),axis.ticks.x = element_blank()) p <- p + theme(axis.title.y = element_blank(),axis.ticks.y = element_blank()) p <- p + labs(x = "", y = "") p <- p + theme_classic() p 〜
出来上がりはこんな感じ