why ui did not find in r shiny

My code is not working I do not know why! can somebody help me please!

library(shiny)
library(shinydashboard)
freenome<-read_csv("/Users/wenyigong/Library/CloudStorage/OneDrive-nyu.edu/job/freenome/mock_data.csv")
head(freenome)
lifestyle<-tibble(freenome$tobacco_use,freenome$alcohol_use,freenome$drug_use,head=TRUE)
chronic_disease<-tibble(freenome$anemia,freenome$depression,freenome$diabetes,freenome$GERD,freenome$hypercholesterolemia,
                        freenome$hyperlipidemia,freenome$hypertension,freenome$hypothyroidism,head=TRUE)
basic_information<-tibble(freenome$birth_year,freenome$gender,freenome$race_ethnicity,freenome$height,freenome$weight,head=TRUE)
location<-tibble(freenome$id,freenome$site_id,freenome$site_lat_long,head=TRUE)
severe_disease<-tibble(freenome$cancer_type,freenome$IBD_type,HEAD=TRUE)
enroll_information<-tibble(freenome$subject_status,freenome$enrolled_date,freenome$discontinued_date,head=TRUE)
blood_collect<-tibble(freenome$blood_collection_date,freenome$blood_tube_collected,head=TRUE)


ui<- dashboardPage(
  dashboardHeader( title = "freenome"),
  dashboardSidebar(
    sidebarMenu(
      menuItem("lifestyle", tabName = "lifestyle", icon = icon("dashboard")),
      menuItem("chronic_disease", tabName = "chronic_disease", icon = icon("dashboard")),
      menuItem("cohortstudy", tabName = "cohortstudy", icon = icon("dashboard")),
      menuItem("basic_information", tabName = "basic_information", icon = icon("dashboard")),
      menuItem("location", tabName = "location", icon = icon("dashboard")),
      menuItem("enroll_information", tabName = "enroll_information", icon = icon("dashboard")),
      menuItem("blood_collect", tabName = "blood_collet", icon = icon("dashboard")),
    )
    
  ),
  dashboardBody(
    tabItems(
      tabItem(tabName = "lifestyle",
              fluidPage(
                h1("lifestyle",
                   dataTableOutput("lifestyle"))
              )
    ),
    tabItem(tabName = "chronic_disease",
            fluidPage(
              h1("chronic_disease",
                 dataTableOutput("chronic_disease"))
            )),
    tabItem(tabName = "cohortstudy",
            plot("study type","number",freenome$cohort)),
    tabItem(tabName = "basic_information",
            fluidPage((
              h1("basicinformation",
                 dataTableOutput("basic_information"))
            ))),
    tabItem(tabName = "location",
            fluidPage(
              h1("location",
                 dataTableOutput("location"))
            ))
    tabItem(tabName = "enrollinformation",
            fluidPage(
              h1("enrollinformation",
                 dataTableOutput("enroll_information"))
            ))
    tabItem(tabName =" blood_collect",
            fluidPage(
              h1("bloodcollect",
                 dataTableOutput("blood_collect"))
            ))
)

server<-function(input,output){
  output$lifestyle<-renderDataTable("lifestyle")
  output$chronic_disease<-renderDataTable("chronic_disease")
  output$cohortstudy<-renderPlot("freenome$cohort")
  output$basicinformation<-renderDataTable("basic_information")
  output$location<-renderDataTable("location")
  output$enrollinformation<-renderDataTable("enroll_information")
  output$bloodcollect<-renderDataTable("blood_collect")
}


shinyApp(ui,server)

It seems like you are missing lots of () and , to make your code functional.

I would suggest to use one of the RStudio IDE versions and there you will see any issue with your code from a syntax perspective. See below screen shot for an example.

Below you will find your code that is correct from a syntax perspective and reformatted.

library(shiny)
library(shinydashboard)
freenome <-
  read_csv(
    "/Users/wenyigong/Library/CloudStorage/OneDrive-nyu.edu/job/freenome/mock_data.csv"
  )
head(freenome)
lifestyle <-
  tibble(freenome$tobacco_use,
         freenome$alcohol_use,
         freenome$drug_use,
         head = TRUE)
chronic_disease <-
  tibble(
    freenome$anemia,
    freenome$depression,
    freenome$diabetes,
    freenome$GERD,
    freenome$hypercholesterolemia,
    freenome$hyperlipidemia,
    freenome$hypertension,
    freenome$hypothyroidism,
    head = TRUE
  )
basic_information <-
  tibble(
    freenome$birth_year,
    freenome$gender,
    freenome$race_ethnicity,
    freenome$height,
    freenome$weight,
    head = TRUE
  )
location <-
  tibble(freenome$id, freenome$site_id, freenome$site_lat_long, head = TRUE)
severe_disease <-
  tibble(freenome$cancer_type, freenome$IBD_type, HEAD = TRUE)
enroll_information <-
  tibble(
    freenome$subject_status,
    freenome$enrolled_date,
    freenome$discontinued_date,
    head = TRUE
  )
blood_collect <-
  tibble(freenome$blood_collection_date,
         freenome$blood_tube_collected,
         head = TRUE)


ui <- dashboardPage(
  dashboardHeader(title = "freenome"),
  dashboardSidebar(
    sidebarMenu(
      menuItem(
        "lifestyle",
        tabName = "lifestyle",
        icon = icon("dashboard")
      ),
      menuItem(
        "chronic_disease",
        tabName = "chronic_disease",
        icon = icon("dashboard")
      ),
      menuItem(
        "cohortstudy",
        tabName = "cohortstudy",
        icon = icon("dashboard")
      ),
      menuItem(
        "basic_information",
        tabName = "basic_information",
        icon = icon("dashboard")
      ),
      menuItem("location", tabName = "location", icon = icon("dashboard")),
      menuItem(
        "enroll_information",
        tabName = "enroll_information",
        icon = icon("dashboard")
      ),
      menuItem(
        "blood_collect",
        tabName = "blood_collet",
        icon = icon("dashboard")
      ),
    )
    
  ),
  dashboardBody(
    tabItems(
      tabItem(tabName = "lifestyle",
              fluidPage(h1(
                "lifestyle",
                dataTableOutput("lifestyle")
              ))),
      tabItem(tabName = "chronic_disease",
              fluidPage(h1(
                "chronic_disease",
                dataTableOutput("chronic_disease")
              ))),
      tabItem(tabName = "cohortstudy",
              plot("study type", "number", freenome$cohort)),
      tabItem(tabName = "basic_information",
              fluidPage((
                h1("basicinformation",
                   dataTableOutput("basic_information"))
              ))),
      tabItem(tabName = "location",
              fluidPage(h1(
                "location",
                dataTableOutput("location")
              ))),
      tabItem(tabName = "enrollinformation",
              fluidPage(
                h1("enrollinformation",
                   dataTableOutput("enroll_information"))
              )),
      tabItem(tabName = " blood_collect",
              fluidPage(h1(
                "bloodcollect",
                dataTableOutput("blood_collect")
              )))
    )
  )
)


server <- function(input, output) {
  output$lifestyle <- renderDataTable("lifestyle")
  output$chronic_disease <- renderDataTable("chronic_disease")
  output$cohortstudy <- renderPlot("freenome$cohort")
  output$basicinformation <- renderDataTable("basic_information")
  output$location <- renderDataTable("location")
  output$enrollinformation <-
    renderDataTable("enroll_information")
  output$bloodcollect <- renderDataTable("blood_collect")
}


shinyApp(ui, server)

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.