参数" mainPanel"缺少,没有默认值

时间:2018-05-22 21:06:17

标签: r shiny

我遇到错误问题:

  

参数" 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)

提前感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

错过括号以关闭你的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")) ) ) ) ) 。修改后的UI代码如下:

.bind()