【问题标题】:Why shiny didn't call local function in server session?为什么闪亮没有在服务器会话中调用本地函数?
【发布时间】:2020-01-18 00:35:11
【问题描述】:

假设我有一个本地函数:

getres<-function(x, y){
   x^2-y
}

然后我有shiny::server:

server <- function(input, output) {
  reslst<-reactive({
    getres(input$x, input$y)
  })

  output$result <- renderPrint({
    reslst
  })
}

当我执行代码时,它报告没有对象reslst,这意味着本地函数getres 根本没有运行。有什么建议吗?

【问题讨论】:

  • 你的意思是“它没有报告对象reslst”?你有测试吗?
  • 你的意思是output$result &lt;- renderPrint({ reslst(); }) 吗? (注意括号...反应数据通常被称为,而不仅仅是引用。)

标签: r shiny


【解决方案1】:

您是否尝试过在服务器参数中调用您的函数?

server <- function(input, output) {

getres<-function(x, y){
   x^2-y
}

reslst<-reactive({
    getres(input$x, input$y)
  })

  output$result <- renderPrint({
    reslst
  })
}

【讨论】:

    猜你喜欢
    • 2023-01-16
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 2014-09-06
    • 1970-01-01
    • 1970-01-01
    • 2016-02-23
    • 2017-03-29
    相关资源
    最近更新 更多