【问题标题】:shinyApp command in shiny package?闪亮包中的闪亮应用命令?
【发布时间】:2017-06-21 12:35:43
【问题描述】:

我在运行 R 2.15.3 的 RStudio 中安装了 Shiny。 我通过library(shiny) 加载包 但是当我尝试使用 shinyApp 命令时,我会得到以下

library(shiny)
ui <- fluidPage()
server <- function(input,output){}
shinyApp(ui=ui,server=server)

Error: could not find function "shinyApp"

甚至当我尝试使用 R 帮助时:

?shinyApp

答案是:

No documentation for ‘shinyApp’ in specified packages and libraries:
you could try ‘??shinyApp’

而且非常令人失望,因为此命令是您一直需要的基本命令之一!

我不得不提一下,我尝试编译的示例代码来自shiny(shiny.rstudio.com/tutorial)的官方教程!所以基本上它应该可以工作。

有人可以帮我解决这个问题吗!

【问题讨论】:

  • 只是猜测,但您可能想要安装最新的 R 版本?见r-project.org
  • 根据文档,[cran.r-project.org/web/packages/shiny/shiny.pdf], These functions create Shiny app objects from either an explicit UI/server pair ( shinyApp ), or by passing the path of a directory that contains a Shiny app ( shinyAppDir ). You generally shouldn’t need to use these functions to create/run applications; they are intended for interoperability pur- poses, such as embedding Shiny apps inside a knitr document
  • 您看不到文档,因为您使用大写字母编写应用程序。使用 ?shinyApp 代替 ?shinyAPP
  • 您使用的是什么版本的闪亮?请与sessionInfo() 联系。在旧版本中,我认为它曾经被称为runApp()。您使用的是相当旧的 R 版本,因此您可能无法安装最新版本的软件包。
  • 我已将 R 更新为 3.4.0 ,但我仍然遇到同样的问题,并且它出现在 Windows 上。当我使用mac编译它时,它可以正常工作!

标签: r shiny


【解决方案1】:

将 R 更新到 Shiny 所需的版本 (>=3.0.0),然后在 R 中运行 update.packages()

您收到此错误的原因可能是因为您在旧 R 版本下安装了 Shiny,因此您获得了旧版本的 Shiny。当您在 Windows 计算机上更新 R 时,它使用了旧 R 安装中已有的包,即 Shiny 的旧版本。

【讨论】:

    【解决方案2】:

    如前所述,问题来自没有正确配置 R 和闪亮,但是在 RStudio(我假设您正在使用它,因为您正在遵循教程)中,一个更简单的解决方案是单击“运行应用程序”按钮,如果它检测到它丢失,它应该为您提供安装闪亮的选项

    【讨论】:

      猜你喜欢
      • 2020-08-08
      • 2016-12-28
      • 2018-09-03
      • 2014-12-14
      • 1970-01-01
      • 2016-12-18
      • 2023-03-13
      • 2014-09-12
      • 2016-05-23
      相关资源
      最近更新 更多