我的数据如下:
df.plot <-structure(list(color = structure(c(2L, 2L, 3L, 1L, 3L, 4L, 3L,
1L, 4L, 1L, 2L, 4L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 2L,
3L, 3L, 3L, 3L), .Label = c("54", "55", "61", "69"), class = "factor"),
date = structure(c(16687, 16687, 16687, 16687, 16687, 16687,
16688, 16688, 16688, 16689, 16689, 16690, 16693, 16693, 16693,
16694, 16694, 16695, 16695, 16695, 16695, 16696, 16696, 16696,
16696, 16696, 16696), class = "Date"), facet = c("A",
"A", "A", "A", "A", "B",
"B", "A", "B", "B", "B", "B",
"B", "B", "B", "B", "A", "B",
"A", "B", "A", "C", "B", "C",
"C", "B", "C")), class = "data.frame", row.names = c(NA,
-27L), .Names = c("color", "date", "facet"))
下表总结了每个方面/颜色的观察次数
df.plot %>% group_by(facet, color) %>% summarise(n())
---------------------
facet color n()
------- ------- -----
A 54 5
A 55 2
A 61 2
B 54 6
B 55 3
B 61 2
B 69 3
C 61 4
---------------------
ggplot生成此图表:
ggplot(df.plot, aes(x=date, fill=color)) +
geom_dotplot(binwidth=1) +
coord_fixed(ratio=1) +
ylim(0,7) +
facet_grid(facet ~ .)
为什么分数错误?例如,我希望A 54有5分,而情节只有4分。