I've looked at some of the popular threads on this error but none seem to help me with mine.
I'm working with data, trying to create a line graph with dates on the x and lines representing three variables, Attendance (int), Registrants (int), and No.Show (int). I tried as.numeric but that didn't seem to do anything.
Here is my code:
IHS %>%
filter(Start.Date != "2020-11-13", Start.Date != "2021-01-08", Start.Date != "2021-01-15", Start.Date != "2021-05-07") %>%
filter(Template != "Campus Event - IHS Tour (VIRTUAL)") %>%
ggplot(aes(x = Start.Date)) +
geom_line(aes(y = Registrants, color = "Registrants")) +
geom_line(aes(y = Attendance, color = "Attendance")) +
geom_line(aes(y = No.Show, color = "No.Show")) +
theme_classic() +
annotate("rect", xmin = as.Date("2020-11-20"), xmax = as.Date("2021-01-22"), ymin = 0, ymax = 14,
alpha = .09) +
annotate("text", x = as.Date("2020-11-20"), y = 12, label = "No tours\nduring holiday", hjust = -1, vjust = 0.5, size = 3) +
annotate("text", x = as.Date("2021-04-09"), y = 26, label = "26", hjust = .5, vjust = -.9, size = 3) +
annotate("text", x = as.Date("2021-04-09"), y = 15, label = "15", hjust = .5, vjust = -.9, size = 3) +
annotate("text", x = as.Date("2021-04-09"), y = 11, label = "11", hjust = .5, vjust = -.9, size = 3) +
labs(x = "Date", y = "Count")+
ggtitle("IHS Tour Registrants, Attendance, and No Show") +
scale_x_continuous(limits = as.Date(c("2020-09-11","2021-04-30")), breaks = as.Date(c("2020-09-11", "2020-09-18", "2020-09-25", "2020-10-02", "2020-10-02", "2020-10-11", "2020-10-16", "2020-10-23", "2020-10-30", "2020-11-06", "2020-11-06", "2020-11-20", "2020-11-06", "2021-01-22", "2021-01-29", "2021-02-05", "2021-02-12", "2021-02-26", "2021-03-05", "2021-03-12", "2021-03-19", "2021-03-26", "2021-04-09", "2021-04-16", "2021-04-23", "2021-04-30", "2021-04-30"))) +
scale_color_manual(name = "Legend", values = c("#FF8000", "#7A1F2E", "#006699")) +
scale_y_continuous(limits = c(0,27), breaks = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,19,20,21,
22, 23, 24, 25, 26, 27)) +
theme(axis.title.y = element_text(angle = 0, vjust = .5)) +
theme(legend.position = "top") +
theme(axis.title.x = element_text(size=10, face = "bold"),
axis.text.x = element_text(size=10, angle = 90),
axis.text.y = element_text(angle = 0, size = 9),
axis.title.y = element_text(angle=0, size = 10, vjust = .5, face = "bold"))
I know there's a lot going on, I can condense it if that's easier, but I figure since I can't really seem to pinpoint what's going wrong that the whole chunk of code would be good.
The graph was fine at one point, and I was able to produce this:
But then when I tried rerunning the code the graph started to give me the error about discrete value supplied to a continuous scale.