【问题标题】:Issue with Shiny-Gadget in RStudio- does not launch/run - no error returnedRStudio 中 Shiny-Gadget 的问题 - 无法启动/运行 - 未返回错误
【发布时间】:2019-01-25 20:21:54
【问题描述】:

我正在尝试创建我的第一个基本 Shiny Gadget。但是,当我尝试运行有问题的 Shiny 小工具函数时,它只是在控制台窗口中打印 R 函数内容,但实际上并没有运行函数本身。

在故障排除中,如果我单独运行 ui 和服务器组件,然后运行 ​​runGadget 命令,小工具确实会运行,因此某些东西没有从函数初始化或被阻止。

我在网上搜索了运行 Shiny 应用程序的问题,但找不到任何帖子。发生这种情况时,也不会返回任何错误以提供任何线索。

例如,当我尝试运行第一个示例时:

library(miniUI)

myFirstGadget <- function() {
        ui <- miniPage(
                gadgetTitleBar("My First Gadget")
                )
        server <- function(input, output, session) { 
                # The Done button closes the app 
                observeEvent(input$done, { 
                        stopApp()
                })
        } 
        runGadget(ui, server) 
        }

myFirstGadget 

我得到以下返回:

> myFirstGadget
function() {
        ui <- miniPage(
                gadgetTitleBar("My First Gadget")
                )
        server <- function(input, output, session) { 
                # The Done button closes the app 
                observeEvent(input$done, { 
                        stopApp()
                })
        } 
        runGadget(ui, server) 
        }

而不是“收听http://127..0.0.1:7057”和小工具的启动。

【问题讨论】:

    标签: r shiny rstudio


    【解决方案1】:

    您只需将代码的最后一行从 myFirstGadget 更改为 myFirstGadget() 即可运行。当您刚刚使用 myFirstGadget 时,它会向您显示函数的代码。您需要括号来运行函数/您的小工具。

    myFirstGadget <- function() {
      ui <- miniPage(
        gadgetTitleBar("My First Gadget")
      )
      server <- function(input, output, session) { 
        # The Done button closes the app 
        observeEvent(input$done, { 
          stopApp()
        })
      } 
      runGadget(ui, server) 
    }
    
    myFirstGadget() # <---- the only line that I edited
    

    【讨论】:

    • 嗨,大卫,非常感谢您的反馈。这是完全有道理的。我的小学生错误。亲切的问候,帕迪
    猜你喜欢
    • 2017-02-23
    • 1970-01-01
    • 2017-06-12
    • 1970-01-01
    • 1970-01-01
    • 2015-08-09
    • 2015-09-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多