When I try to run the faithful demo shiny app in the project root folder I get the error Error in data$grid : object of type 'closure' is not subsettable
which is code used in different script in a sub folder, completely unrelated to the shiny faithful app. However if I run the faithful app from a sub folder it runs correctly. There are several other folders and scripts in the same project. I've closed and re-opened RStudio and deleted the history file but get the same error. Is something corrupt?
#
# 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)
CodePudding user response:
When the shiny app runs, it loads all scripts in the ./R directory (relative to the app itself), which is a useful way to add additional functions etc. to support your app (without making your app files enormous). If you don't want those scripts loaded you will either need to move the app somewhere else or the scripts somewhere else, or first set the auto-load option to false as mentioned in a previous question
options(shiny.autoload.r = FALSE)
runApp()