0

我正在尝试使用酒窝和 rCharts 创建最简单的散点图。我很好奇我是否对这种'scatter'类型有误解。当我运行此代码时,y 轴值偏离十倍或更大——几乎就像散点图充当堆叠条形图而不是简单的散点图一样。下面的示例数据完全模仿了我的数据。

testdat1 <- data.frame(Recommend = sample(60:90, 200, replace = T), Quiet = sample(20:60, 200, replace = T),
                       Owner = as.factor(rep(c(1,2), 100)))
summary(testdat1) # no values exceed 90
dtest <- dPlot(Recommend ~ Quiet, groups = 'Owner', data = testdat1, type = 'scatter')
dtest # plotted y-values reach upwards of 450

有什么想法吗?

4

1 回答 1

0

请参阅评论,但可以通过以下代码块完成答案:

require(rCharts)

testdat1 <- data.frame(Recommend = sample(60:90, 200, replace = T), Quiet = sample(20:60, 200, replace = T),
                       Owner = as.factor(rep(c(1,2), 100)))
summary(testdat1) # no values exceed 90
dtest <- dPlot(Recommend ~ Quiet, groups = 'Owner', data = testdat1, type = 'bubble')
#will aggregate as avg by default
dtest$xAxis(type="addMeasureAxis")
dtest

#add x,y, and grouping so now only will aggregate where x,y,and group is exact same
#if still a problem, could a unique id and group on that
dtest$params$groups <- c('Recommend','Quiet','Owner')
dtest # plotted y-values reach upwards of 450
于 2014-04-21T19:53:51.063 回答