1

Here there is a "toy example" with a similar dataset I am working with.

Gender <- rep(c("M","F"),15)
City <- rep(rep(c("City A", "Citi B","City C"),c(2,2,2)),5)
Year   <- rep(2010:2014, c(6,6,6,6,6))
Pop <- floor(runif(30, min = 10000, max = 15000))
df <- data.frame(Gender, City, Year, Pop)

I have the information of the population of males and females (Gender) for different cities (City) over some years (Year). I would like to get a representation of the evolution of the population for the different cities in two different plots (one for males and another one for females), using ggplot2.

Is it there a way to get this representation simultaneously avoiding to run two different plots? It can be hard to get this when the factor has many different levels.

user438383
  • 5,716
  • 8
  • 28
  • 43
R18
  • 1,476
  • 1
  • 8
  • 17

0 Answers0