Давайте попробуем примерно сымитировать вашу структуру данных, поскольку ваш вопрос не содержит никаких данных:
library(ggplot2)
set.seed(69)
df <- data.frame(
ZIP = c(rep("A", 1000), rep("B", 687)),
Count = c(cumsum(round(runif(1000, 0, 0:999))),
cumsum(round(runif(687, 0, 0:686) * 4))),
Date = c(seq(as.POSIXct("2007-09-01"), by = "1 week", length.out = 1000),
seq(as.POSIXct("2013-08-31"), by = "1 week", length.out = 687)))
ggplot(df, aes(Date, Count, colour = ZIP)) +
geom_line() +
scale_colour_manual(values = c("blue", "red"))
Now clearly, if we want these lines to start at the same position on the x axis, the x axis can no longer reflect the absolute date, but rather the time since the first record. So we need to calculate what this would be for each group. The dplyr package can help us here:
library(dplyr)
df %>%
group_by(ZIP) %>%
mutate(Day = as.numeric(difftime(Date, min(Date), units = "days"))) %>%
ggplot(aes(Day, Count, colour = ZIP)) +
geom_line() +
labs(x = "Day since first record") +
scale_colour_manual(values = c("blue", "red"))
введите описание изображения здесь