0
votes

My ui.R looks this

library(shiny)
library(Sim.DiffProc)

shinyUI(fluidPage(
      titlePanel("Sliders"),

      sliderInput(inputId = "theta",label="Theta:",
                  min=1, max=50, value=5),

      plotOutput("SDE")
    ))

And the server.R is the following

library(shiny)
library(Sim.DiffProc)


shinyServer(function(input, output)
{
  result<-reactive({
    f<-expression(x*(1-(x/1000))^input$theta*0.5)
    g<-expression(x*(1-(x/1000))^input$theta*0.2)
    snssde1d(drift=f,diffusion=g, M=5, x0=100)
  })

  output$SDE<-renderPlot({
    plot(result(), plot.type="single", col="lightgrey")})

})

I always get the following error: object 'input' not found I can't figure out what's the problem. Why is not reacting my theta? Thank you for help!

1
drift coefficient: an expression of two variables t and x. (this is f), diffusion coefficient: an expression of two variables t and x (this is g) - sanyi14ka
the program work correctly in R. I just can't implement in the right way in Shiny - sanyi14ka
Your issue is not the Rshiny. It is the usage of the expression function. The expression function is not evaluating input$theta. You need to understand what input the expression function accepts. For instance, if you replace input$theta, 5. It does produce an output. - user5249203

1 Answers

0
votes

So, As I mentioned the issue of your problem is not Rshiny. It is the usage of the expression.

What you are doing here is

expression(x*(1-(x/1000))^input$theta*0.2)

Which basically outputs the same expression without substituting input$theta, for the value 5.

What you need to do is below

 f <- as.expression(bquote(x*(1-(x/1000))^.(input$theta)*0.2))

#bquote evaluates the expression enclosed in .()

This outputs

expression(x * (1 - (x/1000))^5 * 0.2)

I hope it solved your problem