ggvis - Interactive X axis for bar chart

爷,独闯天下 提交于 2019-11-29 07:11:19

First of all you need to melt your data.frame like this:

library(reshape2)
company <- melt(company, measure.vars=c('Role','Age','Sex'))

And then the following worked for me:

#Barcharts - Age
company %>% ggvis(~value, opacity := 0.8) %>%
  #use filter to pick only the category you want
  filter(variable == eval(input_select(choices=c('Role','Age','Sex')))) %>%
  layer_bars()

I cannot upload the interactive version but the plot looks like this:

And you can pick the category you like

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