I have this short data frame:
population.served <- c(200:210)
area <- c("Cambridge", "Oxford","Cambridge", "Oxford", "Cambridge", "Oxford","London","Cambridge", "Oxford", "London","Edinburgh")
year <- c("Year.1", "Year.1","Year.2", "Year.2","Year.3", "Year.3","Year.3", "Year.4", "Year.4","Year.4","Year.4" )
data <- data.frame(population.served, area, year)
How do I make it so that all area and year entries include a value for the population.served, even if they are zero values?
I want the data to look like this:
population.served <- c(200, 201, 0, 0, 202, 203, 0, 0, 204, 205, 206, 0, 207, 208, 209, 210)
area <- c("Cambridge", "Oxford","London","Edinburgh", "Cambridge", "Oxford","London","Edinburgh","Cambridge", "Oxford","London","Edinburgh","Cambridge", "Oxford","London","Edinburgh")
year <- c("Year.1", "Year.1","Year.1", "Year.1","Year.2", "Year.2","Year.2", "Year.2","Year.3", "Year.3","Year.3", "Year.3","Year.4", "Year.4","Year.4","Year.4" )
data2 <- data.frame(population.served, area, year)