The validate(need()) code to limit the number of effects shown in a forest plot works locally, but struggles on shinyapps.io - there, something more complex may be needed, along these lines:
output$foreststudies <- renderPlot({
tryCatch({
df <- df_filtered()
#TK: consider different forest plot package that is easier to handle
if(nrow(df) > 250) {
stop("Forest plots can only be displayed here with 250 effect sizes or fewer. Please filter the dataset further before proceeding.")
}
rve <- robumeta::robu(metaUI__effect_size ~ 1, data = df, studynum = metaUI__study_id, var.eff.size = metaUI__variance, small = FALSE)
robumeta::forest.robu(rve, es.lab = "metaUI__es_label", study.lab = "metaUI__study_id", "Effect size" = metaUI__effect_size)
}, error = function(e) {
# This will stop the execution and display the error message in the plot output
plot(NA, xlim = c(0, 1), ylim = c(0, 1), type = "n", xlab = "", ylab = "", axes = FALSE)
text(0.5, 0.5, paste(e$message), cex = 1.2, col = "red")
})
}, height = function() {
# Safeguard in case df_filtered() is NULL or has an unexpected error
df <- tryCatch({
df_filtered()
}, error = function(e) {
return(NULL)
})
if(is.null(df) || nrow(df) > 250) {
return(200) # Default height if df is NULL
} else {
return(400 + 25 * nrow(df_filtered()))
}
}, width = 900)
The validate(need()) code to limit the number of effects shown in a forest plot works locally, but struggles on shinyapps.io - there, something more complex may be needed, along these lines: