Currently, my code initially allows the user to choose which dataset they want (a choice of two). Then, based on what they choose, other build variables for the corresponding subsets of the data sets appear. This works great, except that I would like the plots to be overlapped on the same plot, and not separately, as they appear by default.
I have a default graph, plot_Total, and the other parameters in the datasets are looking at specific subsets of this. Therefore, it would be wise to have only 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 is this piece of code not working? It simply creates spaces for each (unwanted) graph, which says: "Error: plot.new has not yet been called." How to specify to add these lines to the default chart (plot_Total)?
source share