Wednesday, February 20, 2019

r - "ERROR: An error has occurred. Check your logs or contact the app author for clarification."



I am trying to set up my first Shiny app and I'm running into this error message:



"ERROR: An error has occurred. Check your logs or contact the app author for clarification."




I see the "reactive: plotObj" and I think that may be the issue but I do not have an actual (labeled) reactive item. I can include my ui.R and server.R if that will clarify any issues. I am gone through the code looking for errors that are glaring and they aren't apparent to me.



I have copied my logs and there are as follows:



2019-06-21T20:31:49.080604+00:00 shinyapps[991225]: Server version: 1.7.6-6
2019-06-21T20:31:49.080607+00:00 shinyapps[991225]: LANG: en_US.UTF-8
2019-06-21T20:31:49.080652+00:00 shinyapps[991225]: R version: 3.5.2
2019-06-21T20:31:49.080654+00:00 shinyapps[991225]: shiny version: 1.3.2
2019-06-21T20:31:49.080655+00:00 shinyapps[991225]: httpuv version: 1.5.1

2019-06-21T20:31:49.080656+00:00 shinyapps[991225]: rmarkdown version:
(none)
2019-06-21T20:31:49.080676+00:00 shinyapps[991225]: jsonlite version: 1.6
2019-06-21T20:31:49.080656+00:00 shinyapps[991225]: knitr version: (none)
2019-06-21T20:31:49.080687+00:00 shinyapps[991225]: RJSONIO version: (none)
2019-06-21T20:31:49.080687+00:00 shinyapps[991225]: htmltools version:
0.3.6
2019-06-21T20:31:49.080903+00:00 shinyapps[991225]: Using pandoc
at /opt/connect/ext/pandoc2
2019-06-21T20:31:49.305354+00:00 shinyapps[991225]: Using jsonlite for

JSON processing
2019-06-21T20:31:49.312109+00:00 shinyapps[991225]:
2019-06-21T20:31:49.312113+00:00 shinyapps[991225]: Starting R with process
ID: '24'
2019-06-21T20:31:49.393993+00:00 shinyapps[991225]:
2019-06-21T20:31:49.393995+00:00 shinyapps[991225]: Listening on
http://127.0.0.1:33615
2019-06-21T20:31:51.249231+00:00 shinyapps[991225]: Warning: Error in $:
object of type 'closure' is not subsettable
2019-06-21T20:31:51.277783+00:00 shinyapps[991225]: 179: renderPlot

[/srv/connect/apps/Tim_Mullen_Assign_3/app.R#38]
2019-06-21T20:31:51.277786+00:00 shinyapps[991225]: 177: func
2019-06-21T20:31:51.277786+00:00 shinyapps[991225]: 137: drawPlot
2019-06-21T20:31:51.277790+00:00 shinyapps[991225]: 123:

2019-06-21T20:31:51.277790+00:00 shinyapps[991225]: 107: drawReactive
2019-06-21T20:31:51.277791+00:00 shinyapps[991225]: 94: origRenderFunc
2019-06-21T20:31:51.277791+00:00 shinyapps[991225]: 93: output$map
2019-06-21T20:31:51.277792+00:00 shinyapps[991225]: 13: runApp
2019-06-21T20:31:51.277792+00:00 shinyapps[991225]: 12: fn

2019-06-21T20:31:51.277792+00:00 shinyapps[991225]: 7: connect$retry
2019-06-21T20:31:51.277793+00:00 shinyapps[991225]: 6: eval
2019-06-21T20:31:51.277794+00:00 shinyapps[991225]: 5: eval
2019-06-21T20:34:21.993347+00:00 shinyapps[991225]: Server version: 1.7.6-6
2019-06-21T20:34:21.993349+00:00 shinyapps[991225]: LANG: en_US.UTF-8
2019-06-21T20:34:21.993405+00:00 shinyapps[991225]: knitr version: (none)
2019-06-21T20:34:21.993385+00:00 shinyapps[991225]: R version: 3.5.2
2019-06-21T20:34:21.993387+00:00 shinyapps[991225]: shiny version: 1.3.2
2019-06-21T20:34:21.993388+00:00 shinyapps[991225]: httpuv version: 1.5.1
2019-06-21T20:34:21.993388+00:00 shinyapps[991225]: rmarkdown version:

(none)
2019-06-21T20:34:22.240898+00:00 shinyapps[991225]: Starting R with process
ID:'23'
2019-06-21T20:34:21.993409+00:00 shinyapps[991225]: jsonlite version: 1.6
2019-06-21T20:34:22.234937+00:00 shinyapps[991225]: Using jsonlite for
JSON processing
2019-06-21T20:34:21.993442+00:00 shinyapps[991225]: RJSONIO version: (none)
2019-06-21T20:34:21.993453+00:00 shinyapps[991225]: htmltools version:
0.3.6
2019-06-21T20:34:21.993631+00:00 shinyapps[991225]: Using pandoc at

/opt/connect/ext/pandoc2
2019-06-21T20:34:22.240897+00:00 shinyapps[991225]:
2019-06-21T20:34:22.311768+00:00 shinyapps[991225]:
2019-06-21T20:34:22.311770+00:00 shinyapps[991225]: Listening on
http://127.0.0.1:41309


The titlePanel, selectInput, sliderInput, and mainPanel appear to be functioning correctly. The map from percent_map doesn't appear to load all the way through when "published". I am hoping to get the map to populate.



Here is my code. I thank you all for your help!




library(shiny)
library(maps)
library(mapproj)
source("WWW/helpers.R")

ui <- fluidPage(
br(),
tags$em("For updated crime data please visit: ",
tags$a(href = "https://crime-data-explorer.fr.cloud.gov", "Crime Data Explorer")),

titlePanel("Assaults in America, 1973"),

sidebarLayout(
sidebarPanel(
helpText("Create crime maps with the information from USAssaults Dataframe"),

selectInput("var",
label = "Choose a Variable to Display",
choices = c("Assault", "Murder", "Rape"),
selected = "Murder"),

br(),

sliderInput("range",
label = "Rate of Occurances:",
min = 0, max = 100, value = c(0,100)),
br(),

sliderInput("alpha",
label = "Choose an Alpha to Adjust Transparency",
min = 0, max = 1, value = c(0,1))

),

mainPanel(plotOutput("map"))
)
)

server <-function(input, output) {
output$map <- renderPlot({
data <- switch (input$var,
"Assault" = df$Assault,

"Murder" = df$Murder,
"Rape" = df$Rape)
color <- switch (input$var,
"Assault" = "darkgreen",
"Murder" = "black",
"Rape" = "red")
legend <- switch (input$var,
"Number of Assualts" = "% Assualts",
"Number of Murders" = "% Murders",
"Number of Rapes" = "% Rapes")

alpha <- switch(input$var,
"Assault" = df$Assault,
"Murder" = df$Murder,
"Rape" = df$Rape)
percent_map (data, color, legend, input$range[1], input$range[2])
})
}

shinyApp(ui = ui, server = server)


Answer



Error in $: object of type 'closure' is not subsettable means you try to apply $ to a function. Since I don't see where you defined the dataframe df in your code, I suspect that this dataframe does not exist, and R "thinks" df is the function of the stats package (density of the Fisher distribution).


No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...