I'm trying to overlay two line graphs on the same space using R and a shiny web application.
This is the only example I can find with a similar problem, but I don't see how they relate. This is also the only plot that exhibits this problem; the rest of my shiny application graphs are fine.
My code (relevant parts) is
x1 <- c( 10, 25, 19)
x2 <- c( 3, 24, 11)
x3 <- c( 4, 15, 1)
df <- data.frame( "October" = x1, "November" = x2, "August"=x3)
x <- factor(1:3, labels = c("October", "November", "August"))
t1 <- as.numeric(df[1,1:3])
t2 <- as.numeric(df[2,1:3])
plot(t1 ~ x, type="n", ylim=c(min(t1),max(t2)))
lines(t1 ~ x, col="blue")
lines(t2 ~ x, col="red")
But no matter what I change the type of the initial plot to, it gives me horizontal lines at all the plotted points. I originally had it as type="l"
but it did the same thing, so I manually added the line that belongs there, and tried to make the horizontal bars disappear with type="n"
Does anyone have any insight into this problem.
I'd prefer solutions in base R, so not using ggplot.