I have a dataframe with the following information:
Year Total Population UK EEA NON-EEA
2007 60510 54102 1999 4409
2008 60995 54225 2154 4615
2009 61437 54415 2235 4787
2010 61933 54699 2331 4903
2011 62448 54787 2580 5080
2012 62864 55042 2671 5151
2013 63230 55309 2762 5160
2014 63653 55375 3042 5236
2015 64212 55642 3204 5365
How can I create a graph in which I could see the evolution of Total Population per year, but showing UK, EEA and Non-EEA population too, because, when we sum up all 3 variables, we have the data from Total Population column.
Additionaly, I have used this code:
dat <- read.table(text = "Total_Population United_Kingdom EEA Non_EEA
2007 60510 54102 1999 4409
2008 60995 54225 2154 4615
2009 61437 54415 2235 4787
2010 61933 54699 2331 4903
2011 62448 54787 2580 5080
2012 62864 55042 2671 5151
2013 63230 55309 2762 5160
2014 63653 55375 3042 5236
2015 64212 55642 3204 5365", header = TRUE)
library(reshape2)
dat$row <- seq_len(nrow(dat))
dat2 <- melt(dat, id.vars = "row")
library(ggplot2)
ggplot(dat2, aes(x = variable, y = value, fill = row)) +
geom_bar(stat = "identity") +
xlab("\nCountry of Birth") +
ylab("Population\n") +
guides(fill = FALSE) +
theme_bw()
It gives me the barplot, but I was thinking to have something more sophisticated.