我的ui.R看起来这个
library(shiny)
library(Sim.DiffProc)
shinyUI(fluidPage(
titlePanel("Sliders"),
sliderInput(inputId = "theta",label="Theta:",
min=1, max=50, value=5),
plotOutput("SDE")
))
服务器.R是以下
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")})
})
我总是收到以下错误:对象&#39;输入&#39;未找到 我无法弄清楚问题是什么。为什么不对我的theta做出反应? 谢谢你的帮助!
答案 0 :(得分:0)
所以,正如我所提到的,你的问题不是Rshiny。它是expression
的用法。
你在这里做的是
expression(x*(1-(x/1000))^input$theta*0.2)
基本上输出相同的表达式而不用输入$ theta替换值5.
您需要做的是
f <- as.expression(bquote(x*(1-(x/1000))^.(input$theta)*0.2))
#bquote evaluates the expression enclosed in .()
此输出
expression(x * (1 - (x/1000))^5 * 0.2)
我希望它能解决你的问题