I read Hadley Wickham's book on ggplot, but I have problems determining weight over time on a bar graph. Here is an example of data:
dates <- c("20040101","20050101","20060101") dates.f <- strptime(dates,format="%Y%m%d") m <- rbind(c(0.2,0.5,0.15,0.1,0.05),c(0.5,0.1,0.1,0.2,0.1),c(0.2,0.2,0.2,0.2,0.2)) m <- cbind(dates.f,as.data.frame(m))
In this data.frame, the first column shows the dates and each row of the corresponding weights. I would like to draw weights for each year on the histogram using the "fill" argument.
I can display weights in columns using:
p <- ggplot(m,aes(dates.f)) p+geom_bar()
However, this is not quite what I want. I would like to see in each bar the contribution of each weight. Moreover, I donβt understand why I have a strange x-axis format, that is, why β2004-07β and β2005-07β are displayed.
thanks for the help
source share