我感兴趣的是显示两个协变量(消费者属性和提供商属性)上的“大型n”有序调查响应信息。我正在使用R的hexbin包。我希望六边形的大小表示调查响应的数量,六边形的颜色表示线性平均满意度响应。
我似乎找不到文档来说明如何使用hexbin或其他现有的包来做到这一点。
编辑以获得更多说明:
我的数据结构如下:
csr_score pro_score rating
15 16 8
17 18 10
19 12 4其中该数据帧的长度为20,000行。
发布于 2012-11-06 03:14:06
您要查找的关键函数是hexTapply
df <- data.frame (c = runif (1000), p = runif (1000), rating = rnorm (1000))
h <- hexbin (x=df$c, y = df$p, IDs = TRUE, xbins=5)
rating.binned <- hexTapply (h, df$rating, FUN=mean)
df.binned <- data.frame (c = h@xcm, p = h@ycm, freq = h@count, rating = rating.binned)
ggplot (df.binned, aes (x = c, y = p, col = rating, size = freq)) + geom_point ()

https://stackoverflow.com/questions/13237316
复制相似问题