r - 标记$ head中的错误:'closure'类型的对象不是子集

时间:2015-12-24 09:00:58

标签: r closures shiny subset

当我在笔记本电脑上运行我的Shiny应用程序时出现此错误。 在我用库(git2r)添加一行代码之前,应用程序工作正常。 在我的代码下面。

有人可以帮忙吗?感谢。

ui.R

league_desc <- c("Premier League","Serie A","Bundesliga","La Liga")

shinyUI(
  fluidPage(
    headerPanel(h1('Football Statistics', align = "center"),
                h2('Data on the 4 main european football leagues. Period 2011 - 2015', align = "center")),
             sidebarPanel(
               h4('Selection Parameters', align = "center"),

这是我的ui.R文件的初始部分。 请注意我正在使用fluidPage命令,即使我没有应用特定的格式化选项(我没有“www”文件夹或“bootstrap.css”文件)。

Shiny Web应用程序的用户界面定义。

library(devtools)
library(git2r)
library(shiny)
library(rCharts)
library(dplyr)
library(rjson)
library(rNVD3)

league_desc <- c("Premier League","Serie A","Bundesliga","La Liga")

shinyUI(
  fluidPage(
    headerPanel(h1('Football Statistics', align = "center"),
                h2('Data on the 4 main european football leagues. Period 2011 - 2015', align = "center")),
             sidebarPanel(
               h4('Selection Parameters', align = "center"),
               radioButtons("League_RB", 
                            "Select League", 
                            league_desc, 
                            selected = "Premier League", 
                            inline = FALSE, 
                            width = NULL),
               radioButtons("Year_RB", 
                                  "Select Season", 
                                  c(2011:2015), 
                                  selected = 2011, 
                                  inline = FALSE, 
                                  width = NULL),
               sliderInput("matchdays", 
                            "Matchdays:", 
                            min = 1,
                            max = 38,
                            value = c(1, 38))
             ),
             mainPanel(
               tabsetPanel(
                       tabPanel(p(icon("line-chart"), "Charts"),
                               h4('Standings', align = "center"),
                               showOutput("chart1"),
                               h4('Shots & Goals', align = "center"),
                               showOutput("chart2"),
                               h4('Relationship Shots vs Goals', align = "center"),
                               showOutput("chart3"),
                               h4('Fouls', align = "center"),
                               showOutput("chart4")),
                       tabPanel(p(icon("table"), "Full Data"),
                                dataTableOutput("dataTable")),
                       tabPanel(p(icon("cogs"), "Regression"),
                                h4('Predict Number of Goals based on Number of Shots on Target', align = "left"),
                                numericInput("sot","1) Expected Number of Shots on Target",value=0,min=0),
                                radioButtons("League_Pred_RB", 
                                             "2) Select League for which you want to predict", 
                                             league_desc, 
                                             selected = "Premier League", 
                                             inline = FALSE, 
                                             width = NULL),
                                h5("3) Click the button to generate the prediction"),
                                actionButton("predButton", "Generate Prediction"),
                                h5('4) Number of Goals Predicted, based on Historical Data'),
                                verbatimTextOutput("pred_goals"),
                                br(),
                                h4('Average Number of Goals, SOT and Regression Coefficients in the period 2011 - 2015', align = "left"),
                                dataTableOutput("regressionTable")
                       )
               )
    )
)
)

1 个答案:

答案 0 :(得分:3)

两个包具有相同功能的问题。

tagshiny中取消屏蔽功能unloadNamespace("shiny")并在所有包require(shiny)

之后再次加载

运作良好。如果您需要标记而不是闪亮使用::

library(devtools) 
        library(git2r)
    unloadNamespace("shiny")
        library(shiny)
        library(rCharts)
        library(dplyr)
        library(rjson) 
library(rNVD3)




        league_desc <- c("Premier League","Serie A","Bundesliga","La Liga")

        shinyUI( fluidPage(
          headerPanel(h1('Football Statistics', align = "center")
                      , h2('Data on the 4 main european football leagues. Period 2011 - 2015', align = "center")),
          sidebarPanel( h4('Selection Parameters', align = "center"),
                        radioButtons("League_RB", "Select League", league_desc, selected = "Premier League", inline = FALSE, width = NULL),
                        radioButtons("Year_RB", "Select Season", c(2011:2015), selected = 2011, inline = FALSE, width = NULL), 
                        sliderInput("matchdays", "Matchdays:", min = 1, max = 38, value = c(1, 38)) ),
          mainPanel( tabsetPanel(
            tabPanel(p(icon("line-chart"), "Charts"),
                     h4('Standings', align = "center") ,

                     showOutput(outputId = "chart1"),
                     h4('Shots & Goals', align = "center"),

                     showOutput("chart2"), h4('Relationship Shots vs Goals', align = "center"), 
                     showOutput("chart3"), h4('Fouls', align = "center"),
                     showOutput("chart4")
                    ), 
            tabPanel(p(icon("table"), "Full Data"), dataTableOutput("dataTable")),
            tabPanel(p(icon("cogs"), "Regression"), h4('Predict Number of Goals based on Number of Shots on Target', align = "left"), 
                     numericInput("sot","1) Expected Number of Shots on Target",value=0,min=0), 
                     radioButtons("League_Pred_RB", "2) Select League for which you want to predict", league_desc, selected = "Premier League", inline = FALSE, width = NULL), 
                     h5("3) Click the button to generate the prediction"), 
                     actionButton("predButton", "Generate Prediction"),
                     h5('4) Number of Goals Predicted, based on Historical Data'),
                     verbatimTextOutput("pred_goals"),
                     br(),
                     h4('Average Number of Goals, SOT and Regression Coefficients in the period 2011 - 2015', align = "left"),
                     dataTableOutput("regressionTable") ) ) ) ) )