r - 缺少参数“mainPanel”,没有默认值
问题描述
我有一个错误问题:
缺少参数“mainPanel”,没有默认值
我有类似问题的搜索论坛,但我是初学者,所以一些琐碎的事情可能是错误的。
mainPanel 也没有丢失,逗号是正确的。你有什么建议吗?
csv 文件可通过以下链接获得: https ://ufile.io/wknza
请看代码:
library(shiny)
library(fmsb)
library(ggplot2)
nba2 = read.csv("headerlivingconditionsPos.csv", header = TRUE, sep = ",")
nba = read.csv("livingconditions.csv", header = TRUE, sep = ",")
header = read.csv("headerlivingconditions.csv", header = TRUE, sep = ",")
nbaSelectAttributes = nba2
nbaSelectAttributes$COUNTRIES <- NULL
nbaSelectAttributes$TEAM <- NULL
nba2$X <- NULL
attributes <- attributes(nbaSelectAttributes)$names
countriesName = attributes(nba$COUNTRIES)$levels
teams = attributes(nba$TEAM)$levels
ui <- fluidPage(
titlePanel("NBA Analysis Application"),
navlistPanel(
"Menu",
tabPanel("COUNTRIES Comparison",
sidebarLayout(
sidebarPanel(
selectInput("country1", "Choose the first country:",
choices = countriesName),
selectInput("country2", "Choose the second contry:",
choices = countriesName),
column(12,
checkboxGroupInput("checkGroup",
h3("Choose the stats that you want to compare (at least 3):"),
choices = list("Housing" = "HOUSING",
"Income" = "INCOME",
"Jobs" = "JOBS",
"Community" = "COMMUNITY",
"Education" = "EDUCATION",
"Environment" = "ENVIRONMENT",
"Civic Engagement " = "CIVIC ENGAGEMENT",
"Health " = "HEALTH ",
"Life satisfaction" = "LIFE SATISFACTION",
"Safety" = "SAFETY",
"Work Life Balance" = "WORK LIFE BALANCE",
selected = "JOBS"))
),
mainPanel(
plotOutput("radarChart"),
p("Every variable is measured in scale of 0 to 10.")
)
)
),
tabPanel("Info",
fluidRow(
shiny::column(6, offset = 0, h1("Probando"))
)
)
)
),
server <- function(input, output) {
output$radarChart <- renderPlot({
nba$TEAM <- NULL
pl1 <- subset(nba, COUNTRIES == input$country1)
pl2 <- subset(nba, COUNTRIES == input$country2)
merge1 <- rbind(header, pl1)
merge2 <- rbind(merge1, pl2)
###
datasetInput <- reactive({
perm.vector <- as.vector(input$checkGroup)
perm.vector
})
###
final = subset(merge2, select = c(input$checkGroup) )
final$COUNTRIES <- NULL
colors_border=c( rgb(0.2,0.5,0.5,0.9), rgb(0.8,0.2,0.5,0.9) , rgb(0.7,0.5,0.1,0.9) )
colors_in=c( rgb(0.2,0.5,0.5,0.4), rgb(0.8,0.2,0.5,0.4) , rgb(0.7,0.5,0.1,0.4) )
radarchart( final , axistype=1 ,
#custom polygon
pcol=colors_border , pfcol=colors_in , plwd=4 , plty=1,
#custom the grid
cglcol="grey", cglty=1, axislabcol="grey", cglwd=0.8,
#custom labels
vlcex=0.8
)
legend(x=1.5, y=1, legend = c(input$COUNTRIES1, input$COUNTRIES2), bty = "n", pch=20 , col=colors_in , text.col = "grey", cex=1.2, pt.cex=3)
datasetInput
})
}
)
shinyApp(ui = ui, server = server)
提前感谢您的帮助!
解决方案
错过了sidebarPanel
在您的 ui 中关闭的括号。修改后的 UI 代码如下:
ui <- fluidPage(
titlePanel("NBA Analysis Application"),
navlistPanel(
"Menu",
tabPanel("COUNTRIES Comparison",
sidebarLayout(
sidebarPanel(
selectInput("country1", "Choose the first country:",
choices = countriesName),
selectInput("country2", "Choose the second contry:",
choices = countriesName),
column(12,
checkboxGroupInput("checkGroup",
h3("Choose the stats that you want to compare (at least 3):"),
choices = list("Housing" = "HOUSING",
"Income" = "INCOME",
"Jobs" = "JOBS",
"Community" = "COMMUNITY",
"Education" = "EDUCATION",
"Environment" = "ENVIRONMENT",
"Civic Engagement " = "CIVIC ENGAGEMENT",
"Health " = "HEALTH ",
"Life satisfaction" = "LIFE SATISFACTION",
"Safety" = "SAFETY",
"Work Life Balance" = "WORK LIFE BALANCE",
selected = "JOBS"))
)
),
mainPanel(
plotOutput("radarChart"),
p("Every variable is measured in scale of 0 to 10.")
)
)
),
tabPanel("Info",
fluidRow(
shiny::column(6, offset = 0, h1("Probando"))
)
)
)
)
推荐阅读
- arrays - JOLT 根据键字段的存在过滤数组元素
- r - 是否可以在 R 中编写对用户输入请求的响应?
- javascript - 如何在 JavaScript 中计算屏幕纵横比?
- angularjs - AngularJS ngSubmitted 是错误的
- postgresql - 从数据库 postgres 运行 pentaho 作业
- elasticsearch - 有什么方法可以查看为什么我的 v7.6 Elasticsearch 映射不起作用并默认为基本映射?
- c# - 继承和随机函数 c#
- jquery - 如何使用 DataTables 添加自定义查看更多详细信息按钮?
- r - 有没有办法确定数据集中有多少行对于多个条件(列)具有相同的分类变量?
- javascript - 未通过 Ajax POST 调用 MVC 控制器中的 HttpPost