r-tag $ head中的错误:“ closure”类型的对象不可子集化 [英] r - Error in tag$head: object of type 'closure' is not subsettable
问题描述
在笔记本电脑上运行Shiny应用程序时出现此错误。
应用程序正常运行,然后添加了带有library(git2r)的代码。
在我的代码下方。
有人可以协助吗?谢谢。
ui.R
league_desc<-c(高级联赛,意甲,德甲联赛,西甲)
ShinyUI(
fluidPage(
headerPanel(h1( '足球统计数据',align = center),
h2('欧洲四个主要足球联赛的数据。2011年至2015年',align = center)),
sidebarPanel(
h4('选择参数',align = center),
这是初始部分ui.R文件的
请注意,即使我没有应用特定的格式设置选项(我也没有 www文件夹或 bootstrap.css文件),但我使用的是FluidPage命令。
Shiny Web应用程序的用户界面定义。
库(devtools)
库(git2r)
库(发光)
库(rCharts)
库(dplyr)
库(rjson)
库(rNVD3)
League_desc<-c(高级联赛,甲级联赛, Bundesl iga,西甲联赛)
ShinyUI(
fluidPage(
headerPanel(h1('Football Statistics',橄榄球='center),
h2( '有关欧洲四个主要足球联赛的数据。 2011年-2015年',align = center)),
sidebarPanel(
h4('Selection Parameters',align = center),
radioButtons( League_RB,
选择联赛,
League_desc,选中的
=高级联赛,
内联= FALSE,
宽度= NULL),
radioButtons( Year_RB ,
选择季节,
c(2011:2015),选定的
= 2011,
内联= FALSE,
宽度= NULL),
slideInput (比赛日,
比赛日:,
的最小值= 1,
的最大值= 38,
的值= c(1,38))
),
mainPanel(
tabsetPanel(
tabPanel(p(icon( line-chart), Charts)),
h4('Standings',align = center),
showOutput( chart1),
h4('Shots&目标,align = center),
showOutput( chart2),
h4('Relationship Shots vs Goals',align = center),
showOutput( chart3 ),
h4(犯规,align = center),
showOutput( chart4)),
tabPanel(p(icon( table),完整数据 ),
dataTableOutput( dataTable)),
tabPanel(p(icon( cogs), Regression),
h4('根据射门次数预测目标数在目标上,align = left),
numericInput( sot, 1)在目标上的预期发射次数,value = 0,min = 0),
radioButtons( League_Pred_RB ,
2)选择您要预测的联赛,
League_desc,选择的
=高级联赛,
内联= FALSE,
宽度= NULL),
h5( 3)单击按钮生成预测),
actionButton( predButton, Generate Prediction),
h5('4)根据历史数据预测的目标数'),
verbatimTextOutput( pred_goals),
br(),
h4( 2011-2015年期间的平均目标数量,SOT和回归系数,align = left),
dataTableOutput( regressionTable)
)
)
)
)
)
问题二包具有相同的功能。
要取消屏蔽 shiny $ c $中的功能
tag
c>我 unloadNamespace( shiny)
并在所有软件包 require(shiny)
$ b
效果很好。如果您需要不闪亮的标签,请使用 ::
library(devtools )
库(git2r)
unloadNamespace( shiny)
库(光泽)
库(rCharts)
库(dplyr)
库(rjson )
库(rNVD3)
League_desc<-c(高级联赛,意甲,德甲联赛,西甲联赛)
ShinyUI(fluidPage(
headerPanel(h1('Football Statistics',align = center))
,h2('欧洲四大足球数据2011年-2015年',align = center)),
sidebarPanel(h4('Selection Parameters',align = center),
radioButtons( League_RB, Select League ,League_desc,选定=高级联赛,内联= FALSE,宽度= NULL),
radioButtons( Year_RB, Select Season,c(2011:2015),选定= 2011,内联= FALSE,宽度= NULL),
SliderInput( matchdays, Matchdays:,最小值= 1,最大值= 38,值= c(1,38))),
mainPanel(tabsetPanel(
tabPanel(p(icon( line -chart), Charts),
h4('Standings',align = center),
showOutput(outputId = chart1),
h4(射击与目标,align = center),
showOutput( chart2),h4(关系射击与目标,align = center),
showOutput( chart3 ),h4('Fouls',align = center),
showOutput( chart4)
),
tabPanel(p(icon( table),完整数据 ),dataTableOutput( dataTable)),
tabPanel(p(icon( cogs), Regression),h4('根据目标的射门次数预测目标数',align = left ),
numericInput( sot, 1)预期的目标射击数量,value = 0,min = 0),
radioButtons( League_Pred_RB, 2)选择要为其选择联赛的联赛您要预测的,League_desc,selected =高级联赛,内联= FALSE,宽度= NULL),
h5( 3)单击按钮生成预测),
actionButton( predButton,生成预测),
h5('4)数字o f根据历史数据预测的目标'),
verbatimTextOutput( pred_goals),
br(),
h4( 2011年期间的平均目标数量,SOT和回归系数) -2015',align = left),
dataTableOutput( regressionTable)))))))))))))))))))))))))))))))))))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")
)
)
)
)
)
解决方案 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") ) ) ) ) )
这篇关于r-tag $ head中的错误:“ closure”类型的对象不可子集化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!