I am trying to plot multiple sets of points on a plot in an R Shiny app, using renderPlot. I've tried using the points function into a for loop which didn't work. I then tried with lapply. Here is what I currently have in the server file:
output$session_plot_Q <- renderPlot({
plot(sectors[which(sectors$Minisector == 0),]$X, sectors[which(sectors$Minisector == 0),]$Y)
lapply(1:25, function(x) {
points(sectors[which(sectors$Minisector == x),]$X, sectors[which(sectors$Minisector == x),]$Y)
})
})
I am getting an output of only the set of points contained in the "plot" function, the first set of point to plot. That means everything in the lapply is getting ignored.
Thanks for your help.
Edit: turns out the issue was the absence of xlim and ylim parameters in the Plot function, thus making only the first set of points visible. By increasing the range of the axes all the points were visible.