我正在努力学习ggvis,我正在波士顿做一个教程。基本上,我试图将我在R.中的波士顿数据中的ggg流程图转换为ggvis,似乎我不能在ggvis中添加水平中线。虽然我在googling搜索后发现了一些黑客,但我仍然不知道如何在我的代码中解决它。这是我的密码:
library(dplyr, warn.conflicts = FALSE)
library(ggvis)
Boston %>%
ggvis(~chas, ~log(medv), fill=~chas, opacity := 0.8) %>%
layer_boxplots(size := 10)所以,这就是情节,我想加一个平均线。这就是我试过的:
data_line = data.frame(
x_rng = c(0,1), #this is the part that I couldn't figure out.
y_rng = c(3,3)
)
layer_lines(~x_rng, ~y_rng, data=data_line) #this is what I added to the code above. 这并没有产生我想要的。事实上,这给了我一个错误。
## Error in new_prop.default(x, property, scale, offset, mult, env, event, :
## Unknown input to prop: c(0, 1)c(3, 3)发布于 2015-07-28 03:59:05
你就不能用dplyr在波士顿数据帧中添加一个平均值的新列吗?mutate(boston, line=mean("what you want the mean of")
然后添加%>% layer_paths(~x,~meanvalue,stroke:=black)
https://stackoverflow.com/questions/31666210
复制相似问题