R语言 在项目根文件夹中的应用程序中运行时出现应用程序 Flink 错误

dsekswqp  于 2023-01-10  发布在  Flink
关注(0)|答案(1)|浏览(466)

当我尝试在项目根文件夹中运行忠实的演示闪亮应用程序时,我得到错误Error in data$grid : object of type 'closure' is not subsettable,这是子文件夹中不同脚本中使用的代码,完全无关的光辉忠实的应用程序。但是,如果我运行忠实的应用程序从一个子文件夹,它运行正确。有几个其他文件夹和脚本在同一个项目。我已经关闭,并重新打开RStudio并删除历史文件,但得到相同的错误。是否有损坏?

#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
#    http://shiny.rstudio.com/
#

library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(

    # Application title
    titlePanel("Old Faithful Geyser Data"),

    # Sidebar with a slider input for number of bins 
    sidebarLayout(
        sidebarPanel(
            sliderInput("bins",
                        "Number of bins:",
                        min = 1,
                        max = 50,
                        value = 30)
        ),

        # Show a plot of the generated distribution
        mainPanel(
           plotOutput("distPlot")
        )
    )
)

# Define server logic required to draw a histogram
server <- function(input, output) {

    output$distPlot <- renderPlot({
        # generate bins based on input$bins from ui.R
        x    <- faithful[, 2]
        bins <- seq(min(x), max(x), length.out = input$bins + 1)

        # draw the histogram with the specified number of bins
        hist(x, breaks = bins, col = 'darkgray', border = 'white',
             xlab = 'Waiting time to next eruption (in mins)',
             main = 'Histogram of waiting times')
    })
}

# Run the application 
shinyApp(ui = ui, server = server)
cgfeq70w

cgfeq70w1#

当这个漂亮的应用程序运行时,它会加载./R目录中的所有脚本(相对于应用程序本身),这是添加附加功能等以支持应用程序的有效方法(而不会让你的应用文件变得巨大)。如果你不想加载这些脚本,你要么需要把应用移到其他地方,要么把脚本移到其他地方,或者先将auto-load选项设置为false,如previous question中所述

options(shiny.autoload.r = FALSE)
runApp()

相关问题