I am trying to plot a long column of subplots using subplot from the plotly package. Right now, the graphs seem to be overlapping and only the first graph is being displayed on top. I am coding in a Rmd file and exporting to an HTML file through the flexdashboard package.
I believe the issue stems from the number of subplots there are.
set.seed(123)
# 61 unique IDS
ids <- c(letters, LETTERS, paste0('id', 1:9))
df <- data.frame(
ID = rep(ids, each = 5),
HOUR = rep(1:5, times = length(ids)),
ARRIVALS = sample(1:50, size = 5*length(ids), replace = TRUE)
)
plots <- lapply(unique(df$ID), function(var) {
loc_df <- df[df$ID == var,]
return (plot_ly(loc_df, x = ~HOUR, y = ~ARRIVALS, type="scatter", mode="line"))
})
subplot(plots, nrows = length(unique(df$ID)))