我正在制作一个闪亮的仪表板,但出现此错误:
Error in tagAssert(body, type = "div", class = "content-wrapper") :
Expected tag to be of type div
我不知道这意味着什么。谷歌搜索给我什么。我有我的dashboardHeader,dashboardSidebar和dashboardBody。这是完整的代码,因为我不知道错误在哪里。 Shiny应用程序正常工作正常,只是将其放入中断的仪表板中。
library(shinydashboard)
shinyApp(ui = dashboardPage(
#Header
dashboardHeader(title = "Basic dashboard"),
#Sidebar
dashboardSidebar(
selectInput("dataset",
"Pick a Project",
choices = c("ALTTobacco - 5/10/17 through 6/11/17",
"BehavioralFactors - 2/13/17 through 3/15/17",
"CobbParks - 4/11/16 through 5/5/16",
"CobbSeniors - 3/16/17 through 5/4/17",
"DDW-16 - 6/21/16 through 6/29/16",
"DDW-17 - 6/19/17 through 6/22/17",
"DDW-18 - 7/9/18 through 7/13/18",
"FortValley2017 - 7/19/17 through 9/10/17",
"Fulton2016 - 8/15/16 through 10/24/16",
"Fulton2018 - 2/19/18 through 3/17/18",
"Habitat2016 - 10/3/16 through 10/12/16",
"JohnsCreek - 4/5/17 through 5/22/17",
"OhioFamily2016 - 9/12/16 through 10/1/16",
"WrightDiabetes - 11/21/16 through 1/22/17"),
selected = "ALTTobacco")
),
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard"),
menuItem("Different Projects", tabName = "project")
),
#Body
dashboardBody(tabItems(
# First tab content
tabItem(tabName = "dashboard",
fluidRow(
plotOutput("distPlot")
)
),
# Second tab content
tabItem(tabName = "project",
fluidRow(
plotoutput("distPlot2"),
plotOutput("distPlot3"),
plotOutput("distPlot4"),
plotOutput("distPlot5")
))
)
)
),
server = function(input, output) {
datasetInput <- reactive({
switch(input$dataset,
"ALTTobacco - 5/10/17 through 6/11/17" = ALTTobacco,
"BehavioralFactors - 2/13/17 through 3/15/17" = BehavioralFactors,
"CobbParks - 4/11/16 through 5/5/16" = CobbParks,
"CobbSeniors - 3/16/17 through 5/4/17" = CobbSeniors,
"DDW-16 - 6/21/16 through 6/29/16" = DDW16,
"DDW-17 - 6/19/17 through 6/22/17" = DDW17,
"DDW-18 - 7/9/18 through 7/13/18" = DDW18,
"FortValley2017 - 7/19/17 through 9/10/17" = FortValley2017,
"Fulton2016 - 8/15/16 through 10/24/16" = Fulton2016,
"Fulton2018 - 2/19/18 through 3/17/18" = Fulton2018,
"Habitat2016 - 10/3/16 through 10/12/16" = Habitat2016,
"JohnsCreek - 4/5/17 through 5/22/17" = JohnsCreek,
"OhioFamily2016 - 9/12/16 through 10/1/16" = OhioFamily2016,
"WrightDiabetes - 11/21/16 through 1/22/17" = WrightDiabetes)
})
output$distPlot <- renderPlot({
dataset <- datasetInput()
my.bp <<-ggplot(data=surv, aes(y= Completes, x=ProjectName, fill=ProjectName ) ) # Creates boxplots
my.bp <- my.bp + geom_boxplot() # Adds color
my.bp <- my.bp + ggtitle("Distribution of Completed Surveys by Project") # Adds a title
my.bp <- my.bp + ylab("Completed Surveys per Day") + xlab("Project") # Adds kaveks
my.bp <- my.bp + coord_flip()
my.bp
})
output$distPlot2 <- renderPlot({
dataset <- datasetInput()
plot(dataset$Date2, dataset$Completes,
xlab = "Number of Days Since Beginning Survey",
ylab = "Number of Completed Surveys Per Day",
title = "Completed Surveys by Number of Days Since Survey Began")
lines(dataset$Date2, dataset$Completes)
abline(h=mean(dataset$Completes, na.rm=TRUE), col="red")
})
output$distPlot3 <- renderPlot({
dataset <- datasetInput()
plot(dataset$Dials, dataset$Completes,
xlab = "Number of Dials Made in a Day",
ylab = "Number of Completed Surveys per Day",
title = "Completed Surveys Compared to Dials Made per Day")
lines(dataset$Dials[order(dataset$Dials)], dataset$Completes[order(dataset$Dials)])
abline(h=mean(dataset$Completes, na.rm=TRUE), col="red")
})
output$distPlot4 <- renderPlot({
dataset <- datasetInput()
plot(dataset$Date2, dataset$Dials,
xlab = "Number of Days Since Beginning Survey",
ylab = "Number of Dials Made in a Day",
tite = "Number of Dials Made per Day Since Survey Began")
lines(dataset$Date2[order(dataset$Date2)], dataset$Dials[order(dataset$Date2)])
abline(h=mean(dataset$Dials, na.rm=TRUE), col="red")
})
output$distPlot5 <- renderPlot({
dataset <- datasetInput()
dataset$DialRatio <- dataset$Dials / dataset$Intervierwers
plot(dataset$Date2, dataset$DialRatio,
xlab = "Number of Days Since Beginning Survey",
ylab = "Ratio of Dials Made over Interviewers Present",
title = "Ratio of Dials Made to Interviewers Present Since Survey Began")
lines(dataset$Date2[order(dataset$Date2)], dataset$DialRatio[order(dataset$Date2)])
abline(h=mean(dataset$DialRatio, na.rm=TRUE), col="red")
})
}
)
答案 0 :(得分:0)
sidebarMenu()
在dashboardSidebar()
之外plotoutput()
而不是plotOutput
您的代码(已更新):
library(shinydashboard)
library(shiny)
shinyApp(ui = dashboardPage(
#Header
dashboardHeader(title = "Basic dashboard"),
#Sidebar
dashboardSidebar(
selectInput("dataset",
"Pick a Project",
choices = c("ALTTobacco - 5/10/17 through 6/11/17",
"BehavioralFactors - 2/13/17 through 3/15/17",
"CobbParks - 4/11/16 through 5/5/16",
"CobbSeniors - 3/16/17 through 5/4/17",
"DDW-16 - 6/21/16 through 6/29/16",
"DDW-17 - 6/19/17 through 6/22/17",
"DDW-18 - 7/9/18 through 7/13/18",
"FortValley2017 - 7/19/17 through 9/10/17",
"Fulton2016 - 8/15/16 through 10/24/16",
"Fulton2018 - 2/19/18 through 3/17/18",
"Habitat2016 - 10/3/16 through 10/12/16",
"JohnsCreek - 4/5/17 through 5/22/17",
"OhioFamily2016 - 9/12/16 through 10/1/16",
"WrightDiabetes - 11/21/16 through 1/22/17"),
selected = "ALTTobacco"),
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard"),
menuItem("Different Projects", tabName = "project")
)
),
#Body
dashboardBody(tabItems(
# First tab content
tabItem(tabName = "dashboard",
fluidRow(
plotOutput("distPlot")
)
),
# Second tab content
tabItem(tabName = "project",
fluidRow(
plotOutput("distPlot2"),
plotOutput("distPlot3"),
plotOutput("distPlot4"),
plotOutput("distPlot5")
))
)
)
),
server = function(input, output) {
datasetInput <- reactive({
switch(input$dataset,
"ALTTobacco - 5/10/17 through 6/11/17" = ALTTobacco,
"BehavioralFactors - 2/13/17 through 3/15/17" = BehavioralFactors,
"CobbParks - 4/11/16 through 5/5/16" = CobbParks,
"CobbSeniors - 3/16/17 through 5/4/17" = CobbSeniors,
"DDW-16 - 6/21/16 through 6/29/16" = DDW16,
"DDW-17 - 6/19/17 through 6/22/17" = DDW17,
"DDW-18 - 7/9/18 through 7/13/18" = DDW18,
"FortValley2017 - 7/19/17 through 9/10/17" = FortValley2017,
"Fulton2016 - 8/15/16 through 10/24/16" = Fulton2016,
"Fulton2018 - 2/19/18 through 3/17/18" = Fulton2018,
"Habitat2016 - 10/3/16 through 10/12/16" = Habitat2016,
"JohnsCreek - 4/5/17 through 5/22/17" = JohnsCreek,
"OhioFamily2016 - 9/12/16 through 10/1/16" = OhioFamily2016,
"WrightDiabetes - 11/21/16 through 1/22/17" = WrightDiabetes)
})
output$distPlot <- renderPlot({
dataset <- datasetInput()
my.bp <<-ggplot(data=surv, aes(y= Completes, x=ProjectName, fill=ProjectName ) ) # Creates boxplots
my.bp <- my.bp + geom_boxplot() # Adds color
my.bp <- my.bp + ggtitle("Distribution of Completed Surveys by Project") # Adds a title
my.bp <- my.bp + ylab("Completed Surveys per Day") + xlab("Project") # Adds kaveks
my.bp <- my.bp + coord_flip()
my.bp
})
output$distPlot2 <- renderPlot({
dataset <- datasetInput()
plot(dataset$Date2, dataset$Completes,
xlab = "Number of Days Since Beginning Survey",
ylab = "Number of Completed Surveys Per Day",
title = "Completed Surveys by Number of Days Since Survey Began")
lines(dataset$Date2, dataset$Completes)
abline(h=mean(dataset$Completes, na.rm=TRUE), col="red")
})
output$distPlot3 <- renderPlot({
dataset <- datasetInput()
plot(dataset$Dials, dataset$Completes,
xlab = "Number of Dials Made in a Day",
ylab = "Number of Completed Surveys per Day",
title = "Completed Surveys Compared to Dials Made per Day")
lines(dataset$Dials[order(dataset$Dials)], dataset$Completes[order(dataset$Dials)])
abline(h=mean(dataset$Completes, na.rm=TRUE), col="red")
})
output$distPlot4 <- renderPlot({
dataset <- datasetInput()
plot(dataset$Date2, dataset$Dials,
xlab = "Number of Days Since Beginning Survey",
ylab = "Number of Dials Made in a Day",
tite = "Number of Dials Made per Day Since Survey Began")
lines(dataset$Date2[order(dataset$Date2)], dataset$Dials[order(dataset$Date2)])
abline(h=mean(dataset$Dials, na.rm=TRUE), col="red")
})
output$distPlot5 <- renderPlot({
dataset <- datasetInput()
dataset$DialRatio <- dataset$Dials / dataset$Intervierwers
plot(dataset$Date2, dataset$DialRatio,
xlab = "Number of Days Since Beginning Survey",
ylab = "Ratio of Dials Made over Interviewers Present",
title = "Ratio of Dials Made to Interviewers Present Since Survey Began")
lines(dataset$Date2[order(dataset$Date2)], dataset$DialRatio[order(dataset$Date2)])
abline(h=mean(dataset$DialRatio, na.rm=TRUE), col="red")
})
}
)