我想基本上创建一个带有com.configuration-management-common
的气球图,其中点的大小是给定坐标处的数据频率。
鉴于data.frame ggplot2
:
d
我想做类似的事情:
d = structure(list(value.x = structure(c(2L, 2L, 3L, 2L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L), .Label = c("Not at all Knowledgeable", "Somewhat Knowledgeable", "Very Knowledgeable"), class = c("ordered", "factor")), value.y = structure(c(5L, 5L, 3L, 5L, 5L, 5L, 5L, 5L, 4L, 4L, 5L, 4L, 4L, 4L, 5L, 4L, 5L, 5L, 4L, 4L), .Label = c("Much less knowledgeable", "Less knowledgeable", "Same as before workshop", "More knowledgeable", "Much more knowledgeable"), class = c("ordered", "factor"))), .Names = c("value.x", "value.y"), row.names = c(NA, 20L), class = "data.frame")
其中数据点与数据发生的次数成正比,但我无法弄清楚如何根据我的需要正确设置点的大小。
重要的是,我希望避免在ggplot(d,aes(value.x,value.y,size=..count..))+geom_point()
中创建一个新列,仅用于计算其他数据集(例如http://www.r-bloggers.com/balloon-plot-using-ggplot2/)的数据计数。这似乎很混乱,如果可以,我想利用d
的力量。
答案 0 :(得分:1)
根据@BenBolker的建议,我找到了使用stat_sum()
的解决方案:
ggplot(d, aes(value.x, value.y, size = ..n..)) + stat_sum()