Shiny Ui.R - Error in Tag("Div", List(...)) - Not Sure Where Error Is

Shiny ui.R - Error in tag(div, list(...)) - not sure where error is

In ui.R, you should not have a comma at the end of this line:

sliderInput("age_cut", "Select Size of Age Brackets:",
min= 3, max= 20, value= 5),

There also shouldn't be a comma at the end of this line

checkboxInput(inputId = "h_own",       label = "Homeownership",         value = FALSE),

In general, you shouldn't have a comma after the last component of a section. Just like with any R function, you don't usually end the function call with a comma. e.g. sum(5,) gives an error.

Error in RShiny ui.r argument missing

Delete the last comma in your ui.R file. It's expecting an argument after the comma.

Error on shiny website, but app works fine locally

If you look at the logs on shinyapps dashboard: shinyapps.io you will notice that the package randomforest, is missing:

2021-06-11T13:23:52.286950+00:00 shinyapps[4258238]: 1 package is needed for this model and is not installed. (randomForest). Would you like to try to install it now?Error in value[[3L]](cond) : Required package is missing.

Including library(randomForest) solves this issue. As far as I can tell, one of your packages relies on randomForest but its developer hasn't listed it as a required package in CRAN.

After adding randomForest, I ran into another problem, which was that the app takes over 60 seconds to load (naive_bayes takes a long time to run), and shinyapps.io times out after 60 secs.

You should separate model fitting and visualisation into separate programs to avoid running fitting and prediction online on shinyapps.

Simple Shiny Code with argument missing

Your problem is:

plotOutput("plot"),  

When you end with "," (since you commented out the line after) it expects a new argument. But it is empty in your case, so remove the extra ",".

Reticulate not accessing data when using within Shiny

The problem is that pydata2 is scoped only locally. python can only access global variables through r..

Thus, you have to define pydata2 on global scope. Yet a better way would be to define a python function which accepts your data as an argument and returns whatever is needed. Then you do not have to pollute your global environment with a copy of pydata2.

This sample code illustrates the problem behind and shows

  1. how to use assign to circumvent it
  2. how to use a function to avoid spamming the .GlobalEnv
library(shiny)
library(reticulate)

globally <- "I am defined globally"

ui <- fluidPage(
fluidRow(
actionButton("run", "Run!")
))

server <- function(input, output, session) {
observeEvent(input$run, {
locally <- "I am defined locally"
assign("local_globally", "I am defined locally but in global scope", envir = .GlobalEnv)
script1 <- paste("try:",
" print(r.globally)",
" print(r.local_globally)",
" print(r.locally)",
"except Exception as inst:",
" print(inst)", sep = "\n")
script2 <- paste("def fun(x):",
" return(x)", sep = "\n")
py_run_string(script1)
py_run_string(script2)
print(py$fun(locally))
})
}

shinyApp(ui, server)

The output on the cosole after pressing the actionButton is:

I am defined globally

I am defined locally but in global scope

Evaluation error: object 'locally' not found.

[1] "I am defined locally"



Related Topics



Leave a reply



Submit