0
votes

Currently developing my first web app with the Shiny package, but unfortunately, after running the code on Rstudio am encountering the following error message:

server <- function(input, output){} shinyApp(ui ,server) Error in force(ui) : object 'ui' not found

What could be the issue?

1

1 Answers

2
votes

Every shiny page has a ui and server element. The problem is that you only have the server defined, and not the ui. See below for an example of a very basic shiny webpage.

library(shiny)

# setwd(dirname(rstudioapi::getActiveDocumentContext()$path))  # set your working directory

# Set the ui section.
ui <- fluidPage(
  h1("Title"),
  selectInput("test.input", "Select a letter", choices = c("a", "b", "c")),
  textOutput("test.output")
)

# Set the server section.      
server <- function(input, output, session) {
  output$test.output <- renderText(
    paste0("You have selected ", input$test.input)
  )
}

shinyApp(ui = ui, server = server)

This shiny app has a basic header, dropdown menu and HTML output, which is all defined in the ui variable. Your page should look like this:

enter image description here

See this page for more about the basic layout of a shiny app.