Update: By playing around with the code for the graph on the shiny homepage, I realised that I had to do this:
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")
if (input$RC) { lines(dat$Year, dat$dat)}
})
This differs from my original code in two ways. Firstly, the conditional is added as just one line within the same reactiveplot function. Secondly, I created a new data.frame which only contains the subset RC. This was initially not working as input$dat$RC, but when RC is a dataframe of its own it works as input$RC.
Points to Chase for steering me in the right direction!