ggplot2 - R ggplot barplot separately for each year -


i know how barplot data separately each year. i'd add excel-image, couldn't cause i'm new in forum. have following data in data frame:

year    2009/10    2010/11    2011/12     2012/13    2013/14 v1     -221.85      0.00       0.00      -138.73     -191.10 v2       0.00     -223.16    -231.52       0.00      -126.85 v3       0.00     -1216.17   -1337.28    -1112.11    -863.98 v4       0.00     -520.87    -540.88     -174.85     -296.78 v5       0.00     -465.48    -805.63     -252.38     -178.92 v6       0.00     -496.25      0.00        0.00      -232.17 v7       0.00       0.00       0.00      -709.63     -759.41 

please me - have tried different approaches without success.

many in advance

steff

not sure if looking for..

dat <- structure(list(var = structure(1:7, .label = c("v1", "v2", "v3",  "v4", "v5", "v6", "v7"), class = "factor"), `2009` = c(-221.85, 0, 0, 0, 0, 0, 0), `2010` = c(0, -223.16, -1216.17, -520.87, -465.48, -496.25, 0), `2011` = c(0, -231.52, -1337.28, -540.88, -805.63, 0, 0), `2012` = c(-138.73, 0, -1112.11, -174.85, -252.38, 0, -709.63), `2013` = c(-191.1, -126.85, -863.98, -296.78, -178.92, -232.17, -759.41)), .names = c("var", "2009", "2010", "2011", "2012", "2013"), class = "data.frame", row.names = c(na, -7l))  library(ggplot2) library(reshape2)  names(dat) <- c("var", "2009", "2010", "2011", "2012", "2013") dat.m <- melt(dat) ggplot(dat.m, aes(x=variable, y=value, fill=var)) + geom_bar(position="dodge", stat="identity") 

enter image description here


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -