I want to plot the assurance curve in RShiny. I tested it in the Rscript and it worked. However, while I implemented into RShiny, it turned out "Error:argument is of length zero". I attached my code below:
output$plot2 = renderPlot({
n = seq(10,250,5)
n_a = input$n_a
n_d = input$n_d
the_0 = input$theta_0
the_1 = input$theta_1
sig1 = input$sig1
alpha = input$alpha
if(input$pt_baynor > 0){
ass_vals = assurance_nd_na(n = n, n_a = n_a, n_d = n_d, theta_0 = the_0, theta_1 = the_1, sigsq = sig1, alt = input$select6, alpha = alpha)
tbl = ass_vals$assurance_table
p2 = ggplot(data = tbl, aes(x = tbl[,1], y = tbl[,2], color = "red"))+
geom_point(size = 3)+
geom_line(lwd = 1.2)+
labs(title = "Assurance Curve",
x = "Sample Size n",
y = "Assurance")+
theme(legend.position = "none")+
theme(axis.text = element_text(size = 20))+
theme(axis.title = element_text(size = 24))+
theme(plot.title = element_text(size = 28))
plot(p2)
} else{}
})
I was expected that there is a assurance plot with a pop out window show in my Shiny app. But it just turned into an error. Thank you!