Hello all R enthusiasts
I have a problem with doing a bar graph that should look like this:
I do not have 10 reputation points so I have to use a link (four bars in one category) http://matma4u.pl/uploads/imgs/pre_1499074482__wyk2.jpg
Generally I would like the same effect
I tried to put four series of charts and post bars but unfortunately did not work out.
I am also convinced that there is a better way
For speeding up my work I send data
dane <- data.frame(kraj=c(1L,2L,3L,4L,5L,6L),
rok=c(rep(2010,6),rep(2014,6)),
Kat1=c(c(1627,1144,1100,1085,983,639),c(1827,1444,1400,1285,1183,1039)),
Kat2=c(c(1500,1244,1168,1110,1002,863), c(1400,1144,1568,1510,999,800))
)
dane
dane$kraj <- factor(d$kraj, levels=1:6, labels=c("Polska", "Niemcy", "Austria", "Rosja", "Ukraina", "Francja"))
dane$rok <- factor(d$rok,levels=c(2010,2014))
ggplot(dane,aes(x = kraj, y = Kat1)) +
geom_bar(stat = "identity", fill = "darkgreen") +
geom_text(aes(y = Kat1,label = format(Kat1, big.mark = " ")), vjust = -0.5, hjust = 0.5, cex = 3)+
geom_bar(aes(y = Kat2), width = 0.5, stat = "identity", fill = "green")+
geom_text(aes(y = Kat2,label = format(Kat2, big.mark = " ")),colour = "red", vjust = -0.5, hjust = 0.5, cex = 3)
My code joins series (kat1, kat2) from two years, no labels are visible, I do not know how to move the bars
I know the values in the image are different, they are examples
Please help with the code design of such a chart