Ada*_*amO 1 r data-visualization
我有兴趣在2个协变量(消费者属性和提供者属性)中显示"大n"序数量表调查响应信息.我正在使用R的hexbin包.我希望六边形的大小表示调查响应的数量和六边形的颜色,以表示线性平均满意度响应.
我似乎无法找到文档,指出如何使用hexbin或其他现有的包.
编辑以获得更多说明:
我的数据结构如下:
csr_score pro_score rating
15 16 8
17 18 10
19 12 4
Run Code Online (Sandbox Code Playgroud)
其中该数据帧的长度为20,000行.
您正在寻找的关键功能是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 ()
Run Code Online (Sandbox Code Playgroud)
