【问题标题】:Error in force(ui) : object 'ui' not found and Error in TagAssertforce(ui) 中的错误:找不到对象 'ui' 并且 TagAssert 中的错误
【发布时间】:2021-07-22 22:30:01
【问题描述】:

我正在构建一个闪亮的应用程序,当我点击运行应用程序时,我收到如下错误:

tagAssert(body, type = "div", class= "content-wrapper") 中的错误: 需要一个具有“shiny.tag”类的对象。

当我单击 Ctrl+Enter 时。这是错误 强制错误(ui):找不到对象“ui”

这是代码。你能帮忙解决这个问题吗

rm(list=ls())
## app.R ##
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(ggplot2)
library(plotly)
library(caTools)
library(caret)
library(Hmisc)
library(data.table)
library(DT)
library(reshape2)
#Estes E9-4
setwd("E:/akshaya/courses/STAR Space/Internship/Team work/Dashboard")
df1 = read.csv("Motor Test Data.csv",stringsAsFactors = F)
View(df1)
# RShiny dashboard
header = dashboardHeader(title = "Solid Motor Test Results")

sidebar = dashboardSidebar(sidebarMenu(id = "tabs",
                                       menuItem("Dashboard", tabName = "Summary", icon = icon("dashboard")),                               
                                       menuItem("Daywise", tabName = "Daywise", icon = icon("chart-line")),
                                       #to get input for a particular tab use conditional panel
                                       conditionalPanel(
                                         "input.tabs == 'Daywise'",
                                         #country selection
                                         selectInput(inputId = "Date", label = "Select Date :", choices = unique(df1$Date_o_fTest),multiple = T)
                                         
                                       ),
                                       
                                       menuItem("Simmulation Summary", tabName = "Model", icon = icon("chart-bar")),
                                       menuItem("Visit-us", icon = icon("send",lib='glyphicon'),href = "https://www.starlabsurat.com/")
)
)

body = dashboardBody(
  tabItems(
    # second tab content
    tabItem(tabName = "Daywise",
            h2("Test Day for the Day"),
            fluidRow(valueBoxOutput("value1",width=3),
                     valueBoxOutput("value2",width=3),
                     valueBoxOutput("value3",width=3)),
    ),
    # third tab content
    tabItem(tabName = "Model",
            h2("Simulation Summary"),
            fluidRow(
              box(title = "Thrust Curve", width = 8,solidHeader = TRUE, collapsible = TRUE,
                  plotlyOutput("plot1",height=250)),
            ),
            
            fluidRow(
              box(title = "Temperature Curve", width = 4,solidHeader = TRUE, collapsible = TRUE,
                  plotlyOutput("plot2",height=250)),
              box(title = "Pressure curve", width = 4,solidHeader = TRUE, collapsible = TRUE,
                  plotlyOutput("plot3",height=250)),
              
            )
    ),
  ))
  
    ui = dashboardPage(header, sidebar, body)
    
    server = function(input, output,session) {
      #for Simulation Summary
      
      output$plot1 = renderPlotly({
        
        ggplotly(ggplot(df1, aes(x=Test_Time_sec, y=Load_Cell_N))+
                   geom_line(size = 1.2,color="red")
                   )
        
      })
      
      output$plot2 = renderPlotly({
        
        ggplotly(ggplot(df1, aes(x=Test_Time_sec, y=Baro_Temp_C))+
                   geom_line(size = 1.2,color="blue")
                   )
        
      })
      
      output$plot3 = renderPlotly({
        
        ggplotly(ggplot(df1, aes(x=Test_Time_sec, y=Baro_Pressure_hpa))+
                   geom_line(size = 1.2,color="green")
                   )
        
      })
      #for Day wise tab 
      
      
      dfsub <- reactive({
        filter(df1,Date_of_Test %in% input$Date)
    })
      # for dashboard view
      Loadvalue <- dfsub[5]
      Tempvalue <- dfsub[6]
      Pressurevalue <- dfsub[7]
      
      output$value1 <- renderValueBox({valueBox(formatC(Loadvalue, format = "f"),'Thrust (in N)',color = "aqua")})
      
      output$value2 <- renderValueBox({valueBox(formatC(Tempvalue, format = "f"),'Thrust (in N)',color = "aqua")})
      output$value3 <- renderValueBox({valueBox(formatC(Pressurevalue, format = "f"),'Thrust (in N)',color = "aqua")})
    }
    
    shinyApp(ui = ui, server = server)
    

【问题讨论】:

    标签: r shiny plotly-dash shinydashboard shinyapps


    【解决方案1】:

    tabItems 后面有个逗号,你必须把它去掉。

        # third tab content
        tabItem(tabName = "Model",
                h2("Simulation Summary"),
                fluidRow(
                  box(title = "Thrust Curve", width = 8,solidHeader = TRUE, collapsible = TRUE,
                      plotlyOutput("plot1",height=250)),
                ),
                
                fluidRow(
                  box(title = "Temperature Curve", width = 4,solidHeader = TRUE, collapsible = TRUE,
                      plotlyOutput("plot2",height=250)),
                  box(title = "Pressure curve", width = 4,solidHeader = TRUE, collapsible = TRUE,
                      plotlyOutput("plot3",height=250)),
                  
                )
        ), #### <-- REMOVE THIS COMMA
      ))
    

    【讨论】:

    • 非常感谢,我删除了逗号,但得到了同样的错误。你能帮忙吗?
    • @Padmasree 它对我有用。如果你得到“ui not found”,那是因为你对ui 的定义有一些错误。复制代码并将其粘贴到 R 控制台中,您将收到错误消息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-03
    • 1970-01-01
    • 1970-01-01
    • 2012-11-20
    • 2014-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多