我不明白为什么 ggplot 不能绘制这个 data.frame :
sample <- dput(melted)
structure(list(alleles = c(98, 100, 102, 106, 124, 126, 128,
132, 134, 142, 144, 145, 146, 147, 148, 149, 151, 152, 153, 156,
158, 159, 165, 167, 169, 171, 173, 175, 177, 181, 184, 187, 193,
194, 196, 197, 200, 228, 233, 234, 238, 240, 241, 242, 243, 244,
245, 246, 247, 249, 251, 253, 363, 364, 365, 367, 371, 377, 380,
384, 391, 98, 100, 102, 106, 124, 126, 128, 132, 134, 142, 144,
145, 146, 147, 148, 149, 151, 152, 153, 156, 158, 159, 165, 167,
169, 171, 173, 175, 177, 181, 184, 187, 193, 194, 196, 197, 200,
228, 233, 234, 238, 240, 241, 242, 243, 244, 245, 246, 247, 249,
251, 253, 363, 364, 365, 367, 371, 377, 380, 384, 391), variable = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Parents", "Nymphes"
), class = "factor"), value = c(11, 17, 13, 1, 1, 18, 5, 8, 10,
6, 9, 1, 25, 17, 2, 1, 1, 2, 0, 2, 0, 2, 1, 1, 8, 9, 6, 10, 35,
1, 3, 4, 20, 3, 2, 39, 2, 0, 0, 1, 8, 25, 2, 27, 6, 8, 0, 3,
1, 8, 1, 2, 14, 17, 2, 5, 1, 2, 1, 2, 0, 12, 49, 33, 0, 4, 35,
6, 7, 14, 7, 25, 0, 44, 26, 3, 0, 6, 0, 9, 3, 1, 0, 1, 4, 15,
22, 8, 24, 69, 0, 2, 5, 35, 2, 18, 92, 0, 2, 6, 0, 22, 44, 6,
56, 13, 12, 1, 6, 2, 21, 0, 3, 12, 9, 5, 3, 0, 1, 1, 0, 1)), .Names = c("alleles",
"variable", "value"), row.names = c(NA, -122L), class = "data.frame")
ggplot 命令:
ggplot(sample,aes(x=alleles,y=value)) + geom_bar(aes(fill=variable),position="dodge") + theme(axis.text.x=element_text(angle = -75, hjust = 0))
错误 :
stat_bin:binwidth 默认为 range/30。使用 'binwidth = x' 来调整它。pmin(y, 0) 中的错误:找不到对象“y”
如果 data.frame 的第一列(等位基因)是一个因素,那么情节就会出来,但是我对数据的排序有问题。我需要列等位基因按顺序排列,如上面的 data.frame 所示。很明显,有什么东西让我无法理解……