boxplot won't display with ggvis

孤街醉人 提交于 2019-12-14 01:42:31

问题


I'm trying to make a boxplot with ggvis and I can't seem to view one even with a simple example

library(dplyr)
library(ggplot2)
library(shiny) #I think this is required? not sure
data.frame(theVar = c(1,5:10,15)) %>% ggvis(x = ~theVar) #makes a histogram

data.frame(theVar = c(1,5:10,15)) %>% ggvis(x = ~theVar) %>% layer_boxplots()

Error: Can't find prop y.update

forcing a y variable:

data.frame(theVar = c(1,5:10,15)) %>% ggvis(x = ~theVar,y=~theVar) %>% layer_boxplots()

seems to turn it into intervals? not sure what its doing but it's not a boxplot, nor should a boxplot need an X and Y...


回答1:


If you have a single variable, you have to use your variable for y and specify a dummy for x:

library(ggvis)
data.frame(theVar = c(1,5:10,15)) %>% ggvis(y = ~theVar, x = ~ 1) %>% layer_boxplots()


来源:https://stackoverflow.com/questions/28457140/boxplot-wont-display-with-ggvis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!