Currently, my code initially lets the user select what dataset they want (A choice of two). Then based on what they choose, other plotting variables for the datasets' respective subsets appear. This works fine, apart from the fact that I would like the plots to be overlain all on one plot, instead of separately as they appear by default.
I have a default plot, plot_Total, and the other options in the datasets are looking at particular subsets of this. So it would make sense to have just one scatter.
output$plot_Total <- reactivePlot(function() {
plot.new()
plot.window(xlim=c(1850,2020), ylim = c(0,5000000))
axis(1)
axis(2)
title(main="Numbers over the years")
title(xlab="Year")
title(ylab="Number of people")
box()
points(dat$Year, dat$Total, col="red")
lines(dat$Year, dat$Total, col="red")
})
output$plot_subset1 <- reactivePlot(function() { lines(dat$Year, dat$subset1) })
output$plot_subset2 <- reactivePlot(function() { lines(dat$Year, dat$subset2) })
why doesnt this code snippet work? It just creates blank spaces for each (unwanted) graph, underneath which it says "Error: plot.new has not been called yet". How do I specify to add these lines to the default (plot_Total) plot?