Rでの私のデータセットは以下のようになります。Rのggplot2:複雑な積み重ね棒グラフ、複数のカテゴリ変数と
a <- c("M","F","F","F","M","M","F","F","F","M","F","F","M","M","F")
p <- c("P","P","W","W","P","P","W","W","W","W","P","P","P","W","W")
y1 <- c("yes","yes","null","no","no","no","yes","null","no","yes","yes","yes","null","no","no")
y2 <- c("yes","null","no","no","no","yes","yes","yes","null","no","yes","null","no","yes","yes")
y3 <- c("no","no","no","yes","null","yes","null","no","no","no","yes","yes","null","no","no")
VE <- data.frame(gender = a,
type = p,
y1 = y1,
y2 = y2,
y3 = y3)
そして、私はこのようになります棒グラフを作成したいと思います: ideal bar chart
Iグラフを得るための長い道のりを見つけただけです。
q<-data.frame(gender=VE$gender,
year=rep("y1",15),
group=VE$y1)
p<-data.frame(gender=VE$gender,
year=rep("y2",15),
group=VE$y2)
x<-data.frame(gender=VE$gender,
year=rep("y3",15),
group=VE$y3)
Table<-rbind(q,p,x)
ggplot(Table, aes(year)) + geom_bar(aes(fill=group), position = "stack") + facet_grid(gender~.)
棒グラフを取得するには良い方法はありますか? (元々、それぞれ32個の変数を持つ3,000,000個のobsevationsに対処する予定だったので) この棒グラフで何か助けてください。乾杯!
画像であなたのデータを示すには、複製が容易になりません。 [this](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)とヘルプを読み、質問を編集してください。またはあなたの[質問](https://stackoverflow.com/questions/38877580/stacked-bar-plot-with-4-categorical-variables-in-r?rq=1)を検索してください。結局あなたの質問の側面。 – shea
[Rの4つのカテゴリ変数を持つ積み重なった棒グラフ]の可能な複製(https://stackoverflow.com/questions/38877580/stacked-bar-plot-with-4-categorical-variables-in-r) – shea