Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

r - Error in tag$head: object of type 'closure' is not subsettable

I got this error when I Run my Shiny app on my laptop. App worked before I added a line of code with library(git2r). Below my code.

Can anyone assist? Thanks.

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"),

This is the initial part of my ui.R file. Please notice I'm using fluidPage command, even if I didn't apply specific formatting option (I haven't either a "www" folder or a "bootstrap.css" file).

The user-interface definition of the Shiny web app.

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")
                       )
               )
    )
)
)
like image 878
NB75 Avatar asked Mar 13 '23 19:03

NB75


1 Answers

Problem that two package have same functions.

To unmask function tag in shiny i unloadNamespace("shiny") and load again after all packages require(shiny)

Works well. If you need tag from not shiny use ::

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") ) ) ) ) )
like image 169
Batanichek Avatar answered Mar 16 '23 07:03

Batanichek