【问题标题】:R shiny app errors with ui.R带有 ui.R 的 R 闪亮应用程序错误
【发布时间】:2015-07-02 01:50:35
【问题描述】:

我知道common mistakes 关于此主题的讨论。我尝试了添加或删除 ID、标签和逗号的各种组合,但我似乎无法弄清楚我的代码有什么问题。

现在我的应用程序没有做任何实质性的事情,我只是想设置它。现在,预期的行为是它运行,允许用户输入任何文本,点击提交按钮,并返回“hello world!”

server.R 代码:

library(shiny)
shinyServer(   
  function(input, output) {
   output$results <- renderText({
              "hello world!"           
              }) 
  }
)                               

ui.R 代码:

library(shiny)
shinyUI(fluidPage(
   titlePanel("Title goes here."),
   sidebarLayout(
      sidebarPanel(
      helpText("Enter a few words, then select 'submit'!"),
      textInput("input"),
      submitButton("submit", label = "submit"),
   ),
mainPanel(
  textOutput("results")
  )
)
))

实际行为在浏览器上返回此错误:

ERROR: argument "label" is missing, with no default

R 控制台中的这个错误:

> shiny::runApp()
Listening on http://127.0.0.1:4635
Error in label %AND% tags$label(label, `for` = inputId) : 
  argument "label" is missing, with no default
Error in label %AND% tags$label(label, `for` = inputId) : 
  argument "label" is missing, with no default

对于调试闪亮应用程序的任何一般性建议将不胜感激!

【问题讨论】:

标签: r debugging shiny


【解决方案1】:

textInput 需要标签,submitButton 不需要。

试试这个:

  textInput("input", "A Label"),
  submitButton("submit")

submitButton 之后还有一个逗号。

不幸的是,我也很新 R,我没有调试 Shiny App 的建议。

【讨论】:

  • 哇,谢谢!我还注意到你删除了一个逗号。呸!你有什么建议让我知道如何尝试而不是我首先尝试的其他 10 件事?
  • 我能够在我的机器上重现,然后我开始锤击代码直到它工作:)
  • 实际上,我用来“调试”您的代码的一种方法是在 RStudio 上按 F1 来确定您使用的函数的必需参数和可选参数
【解决方案2】:

您可以在服务器部分使用browser() 命令调试 R Shiny。执行将在此位置停止

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-24
    • 1970-01-01
    • 2017-03-01
    • 2018-05-24
    • 2021-07-17
    • 2016-05-27
    • 2019-08-07
    • 2021-01-09
    相关资源
    最近更新 更多