You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
Hello, I would like to create a grouped barchart (which is not stacked) using ggvis. #164 I read some other issues which identified this was a work in progress, but since it works in a simple case I assume it is now a usable feature?
I've included some reproducible code for the case that doesn't work. There is also a simple case which does work - so I'm at a loss at this point to troubleshoot further. In my case, instead of dodging the bars, it just paints them on top of one another (both RStudio and Chrome).
I'm using RStudio version 0.99.491 on max
library(XML)
library(ggvis)
library(dplyr)
library(tidyr)
##Farm census datafarms_by_area<-"http://www.omafra.gov.on.ca/english/stats/census/size2.htm"tables<- readHTMLTable(farms_by_area)
farms_by_area<-tables[[2]]
farms_by_area<-farms_by_area[,c(1,2,4,6,8)]
colnames(farms_by_area)[1] <-"farm_size"##Do not include Total, or breakdown beyond 1,600 and over which only applies to last two years##Those are still counted in 1,600 acrs and over rowfarms_by_area=farms_by_area[1:11,]
farms_by_area %>% gather(year,count,-farm_size) %>%
mutate(year=gsub("\\s","",year),count=as.integer(gsub("[-,]","",as.character(count)))) %>%
mutate(farm_size= ordered(farm_size, levels= c("Under 10 acres","10 - 69 acres","70 - 129 acres","130 - 179 acres","180 - 239 acres",
"240 - 399 acres","400 - 559 acres","560 - 759 acres","760 - 1,119 acres","1,120 - 1,599 acres","1,600 acres and over")
),year=factor(year)
) ->farms_by_area_clean## Does not work - painting bars on top of one another instead of dodgingfarms_by_area_clean %>% ggvis(x=~year, y=~count, fill=~farm_size) %>%
layer_bars(stack=FALSE)
## This simple example works fine howeversteps<-c("A","B","C","D","A","B","C","D")
ratio<-c(1.1,1.5,1.7,1.4,1.5,1.7,1.4,1.9)
feature<-c("cc","cc","cc","cc","ca","ca","ca","ca")
shrink<-data.frame(steps,ratio,feature)
shrink %>%
mutate(steps_feature=factor(paste(steps, feature))) %>%
ggvis(x=~steps_feature, y=~ratio, fill=~feature) %>%
layer_bars(stack=FALSE)
I was not able to reproduce this. Pasting the above code resulted in the following plot:
I assume some of the difference is a change in the table the data is scraped from, but the bars are clearly not stacked. This is using ggvis 0.4.3 so maybe that update fixed it.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello, I would like to create a grouped barchart (which is not stacked) using ggvis. #164 I read some other issues which identified this was a work in progress, but since it works in a simple case I assume it is now a usable feature?
I've included some reproducible code for the case that doesn't work. There is also a simple case which does work - so I'm at a loss at this point to troubleshoot further. In my case, instead of dodging the bars, it just paints them on top of one another (both RStudio and Chrome).
I'm using RStudio version 0.99.491 on max
The text was updated successfully, but these errors were encountered: