我正在尝试运行以下Shiny App,但我得到了:
" ERROR:参数" mainPanel"缺少,没有默认"
消息。即使我处理sidebarLayout内部和sidebarPanel外部的mainPanel,我尝试了网上提供的另一个相关解决方案,但错误仍然相同。
请帮助我找出错误并纠正错误。
library(shiny)
shinyUI(pageWithSidebar(
titlePanel("Road Accident"),
sidebarLayout(
sidebarPanel(selectInput('geo', 'Country', choices = list("Unknown" ="AT","BE","CZ","DE","DK","EL","ES","FI","FR",
"IE","IT","LI","LU","NL","PT","RO","SE","UK","PL","SI","BG","CH","CY",
"EE","HU","IS","LV","MT","NO","SK","HR","LT")
)
),
mainPanel(
plotOutput("newHist"))
)
))
library(shiny)
library(ggplot2)
library(dplyr)
library(eurostat)
p1<-get_eurostat("tsdtr420",time_format="num")
p2<-p1[!rowSums(is.na(p1)),]
shinyServer(
function(input, output) {
output$newHist<- renderPlot({
p3 <- filter(p2, grepl(input$geo,geo))
p<-ggplot(data=p3,aes(time,values))+geom_bar(stat="identity")+theme_bw()+theme(legend.position="none")+
labs(title="Road Accidents",x="",y="Victims")
print(p)
output$geo
})
})
答案 0 :(得分:1)
如果你在没有m <- matrix(rnorm(324, mean = 5000, sd = 1000), nrow = 108)
colnames(m) <- paste('V', 1:3, sep = '')
df <- data.frame(type = factor(rep(c('T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'T9'), each = 4)),
treatment = factor(rep(rep(c('C','P', 'N', 'S'), each = 1), 9)),
file = factor(rep(c("file1", "file2", "file3"), each = 36)),
as.data.frame(m))
的情况下这样做,它可以正常工作。您只需要使用sidebarLayout
,?pageWithSidebar
来检查元素的必需参数,等等...... ?sidebarLayout
需要三个参数,您只需要两个参数。
pageWithSidebar