r - same bar width in ggplot2? -
this question has reply here:
a way dodge histogram? 1 replyin example:
library(ggplot2) dat <- data.frame(a=factor(c(1,1,1,2,2,2,3,3,3,4)), b=c("a","b","d","a","b","c","a","b","d",na), c=c(1,4,3,5,5,1,2,2,8,6)) plot <- ggplot(dat,aes(fill=b,x=a,y=c)) plot + geom_bar(width=.7, position=position_dodge(width=.7), stat = "identity")
factor 4
wider other bars. there way create them same width?
ideally should have info every combination if zero. means, 1 in data$a should have info four(a,b,c,d) , on... seek modifying info frame , plot. na category referred "other" here.
library(ggplot2) dat <- data.frame(a=factor(c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4)), b=c("a","b","c","d","other","a","b","c","d","other","a","b","c","d","other","a","b","c","d","other"), c=c(1,4,0,3,0,5,5,1,0,0,2,2,0,8,0,0,0,0,0,6)) plot <- ggplot(dat,aes(fill=b,x=a,y=c)) plot + geom_bar(width=.7, position=position_dodge(width=.7), stat = "identity")
view dataframe know difference. have missing bars corresponding data, dnt good. im afraid might solution.
r ggplot2
No comments:
Post a Comment