首页 > 解决方案 > 如何部署我的闪亮应用程序?(错误打开连接)

问题描述

我似乎无法部署闪亮的应用程序。这是我得到的错误

> deployApp()
Preparing to deploy application...DONE
Uploading bundle for application: 565580...Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file '/var/folders/6_/gqrmklfs2vb00n2ksy7pthgh0000gn/T//RtmpnhMpxa/file63a82fe45b55': No such file or directory

我不确定为什么“R”会在那个特定的位置寻找。当我转到我的 Shiny 仪表板时,我可以看到应用程序已上传,但尚未部署。谢谢。

这是代码的最小版本。它涉及读取文本文件,并将其显示为 .html 对象。

shinyApp(

  ui <- fluidPage(
    sidebarLayout(
      sidebarPanel(
        fileInput("text_file", "Choose text file",
                  multiple = FALSE,
                  accept = c(".txt")
        )
      ),
      mainPanel(htmlOutput("example"))
    )
  ), 

  server <- function(input, output, session){

    text <- reactive({
      req(input$text_file)
      x <- scan(input$text_file$datapath, what = "string", sep = "\n")

    })

    # text output
    output$example <- renderUI({
      HTML(text())
    })
  }



    )

标签: shiny

解决方案


我需要添加一张图片,因此使用 answer 方法:

您是否尝试过使用 RStudio 功能?

更新

我必须编辑您的代码才能获得该选项:

library(shiny)  

ui <- fluidPage(
    sidebarLayout(
      sidebarPanel(
        fileInput("text_file", "Choose text file",
                  multiple = FALSE,
                  accept = c(".txt")
        )
      ),
      mainPanel(htmlOutput("example"))
    )
  )

server <- function(input, output, session){

  text <- reactive({
    req(input$text_file)
    x <- scan(input$text_file$datapath, what = "string", sep = "\n")

  })

  # text output
  output$example <- renderUI({
    HTML(text())
  })
}

shinyApp(ui, server)

闪亮应用出版


推荐阅读