"R ggplot2 누적 막대그래프"의 두 판 사이의 차이

 
4번째 줄: 4번째 줄:
<syntaxhighlight lang='r' notebook>
<syntaxhighlight lang='r' notebook>
df <- read.table( header=TRUE, stringsAsFactors=FALSE, text="
df <- read.table( header=TRUE, stringsAsFactors=FALSE, text="
treatment  size  cases    cases
treatment  size  result  cases
A          small  success  81
A          small  success  81
A          small  failure  6
A          small  failure  6
19번째 줄: 19번째 줄:
<syntaxhighlight lang='r' notebook>
<syntaxhighlight lang='r' notebook>
library(ggplot2)
library(ggplot2)
ggplot(df, aes(txs)) + geom_bar(aes(weight=num,fill=cases)) + labs(x="treament × size")
ggplot(df, aes(txs)) + geom_bar(aes(weight=cases,fill=result)) + labs(x="treament × size")
</syntaxhighlight>
</syntaxhighlight>



2021년 3월 31일 (수) 02:58 기준 최신판

1 개요[ | ]

R ggplot2 누적 막대그래프
df <- read.table( header=TRUE, stringsAsFactors=FALSE, text="
treatment  size   result   cases
A          small  success  81
A          small  failure  6
A          large  success  192
A          large  failure  71
B          small  success  234
B          small  failure  36
B          large  success  55
B          large  failure  25
")
df$txs <- paste0(df$treatment, "×", df$size)
df
library(ggplot2)
ggplot(df, aes(txs)) + geom_bar(aes(weight=cases,fill=result)) + labs(x="treament × size")

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}