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: 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
- how to use
assign
to circumvent it - 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
Visual Bug When Changing Robinson Projection's Central Meridian with Ggplot2
Why "Character Is Often Preferred to Factor" in Data.Table for Key
How to Custom or Display Modebar in Plotly
Increasing Whitespace Between Legend Items in Ggplot2
How to Sort a Vector of Alphanumeric Values Using Lexical Ordering in R
Why Does 1..99,999 == "1".."99,999" in R, But 100,000 != "100,000"
How to Load Any Package in R (Unable to Load Shared Object)
Efficient Method to Filter and Add Based on Certain Conditions (3 Conditions in This Case)
How to Filter Rows Based on the Previous Row and Keep Previous Row Using Dplyr
Count Number of Distinct Values in a Vector
Drawing Minor Ticks (Not Grid Ticks) in Ggplot2 in a Date Format Axis
R: Split String into Numeric and Return the Mean as a New Column in a Data Frame
Tls V1.1/Tls V1.2 Support in Rcurl
How to Create a Single Dummy Variable with Conditions in Multiple Columns
Shiny Error in Match.Arg(Position):'Arg' Must Be Null or a Character Vector
Wordcloud Package: Get "Error in Strwidth(…):Invalid 'Cex' Value"