目標は、ggplot() を使用して積み上げ棒グラフをプロットすることです。まず、データ テーブルを溶かす必要があります。ただし、テーブルを x8.pm に溶かした後、x8.p のゼロ値が NULL (x8.pm$Var.1) になり、データの一部であるゼロが失われました。
x8.p <-structure(c(70, 20, 7, 2, 2, 54, 33, 8, 0, 4, 37, 29, 23, 11,
0, 46, 29, 18, 4, 2, 16, 29, 26, 20, 10, 37, 20, 9, 13, 22, 66,
18, 14, 2, 0, 65, 20, 12, 3, 0, 47, 29, 18, 4, 3, 48, 32, 16,
3, 1, 24, 25, 19, 22, 10, 41, 14, 18, 9, 18, 66, 25, 6, 3, 0,
62, 23, 14, 1, 0, 47, 30, 14, 8, 1, 46, 31, 16, 6, 1, 19, 27,
25, 22, 7, 34, 15, 17, 13, 21, 68, 22, 7, 2, 1, 62, 21, 16, 1,
0, 45, 30, 18, 5, 1, 43, 28, 22, 5, 2, 20, 23, 25, 23, 10, 36,
20, 12, 14, 19, 60, 25, 13, 2, 0, 62, 23, 10, 6, 0, 41, 24, 26,
9, 0, 47, 31, 16, 5, 1, 13, 29, 22, 24, 13, 28, 16, 20, 18, 18
), class = "table", .Dim = c(5L, 6L, 5L), .Dimnames = structure(list(
c("Highly Satisfied", "Moderately Satisfied", "Satisfied",
"Moderately Dis-Satisfied", "Extremely Dis-Satistfied"),
c("I've changed for work/ a new job/ gone on a work plan",
"I want a phone that 2degrees doesn't offer", "I want Best Mates/ Favourites",
"I was offered or saw a better offer on another network",
"Issues with the 2degrees network (poor coverage)", "Other"
), YearQuarter = c("2011-09-01", "2011-12-01", "2012-03-01",
"2012-06-01", "2012-09-01")), .Names = c("", "", "YearQuarter"
)))
x8.p.m <- melt(x8.p, id="var");x8.p.m
ggplot(data=x8.p.m, aes(x=as.factor(YearQuarter), y=value, fill=Var.1,na.rm=TRUE))+ geom_bar(stat="identity")+facet_wrap(~Var.2)