I am having problems simulating data in my shiny app.
It is quite a large app, but what gives the problems is a specific part.
My app creates vectors of simulated data to then create a data frame.
The user introduces the lenght of this vector (number of rows of the final table), and the simulation properties. For example, when working with rnorm the user introduces the mean and standard deviation.
A part of the server.R file would be something like this:
data <- reactive ({
return( rnorm (input$number_rows, input$mean, input$sd)
})
And then create the data frame. All the inputs are numericInput()
This works on the app (the simulated data is shown), but raises an error:
Error in rnorm(input$number_rows, input$mean, input$sd) :
invalid arguments
And the app ends up crashing in the end.
If I use as.numeric() on each of the inputs:
data <- reactive ({
return( rnorm ( as.numeric(input$number_rows), as.numeric(input$mean), as.numeric(input$sd))
})
The error no longer appears, but I get a warning instead:
Warning in run(timeoutMs) : NAs produced
Warning in run(timeoutMs) : NAs produced
They appear at every change I make, and sometimes the app crashes if I perform a lot of changes.
Any idea on how to solve this, or why does this happen??