【发布时间】:2018-12-24 03:32:18
【问题描述】:
以下是绘图的一些示例数据:
Female = c(23,56,77)
Male = c(33,55,22)
Canada = c(44,12,3)
US = c(47,14,9)
Stages = c("Application", "Interview", "Test")
masterFemale = data.frame(Stage, Female, Male)
Country = data.frame(Stages, Canada, US)
我不断收到错误
validateTabName(tabName) 中的错误:tabName 不能有 '.'在里面。
但我不知道它在说什么。我检查了代码中的括号和逗号,逻辑对我来说很有意义。有什么遗漏吗?
##Dashboard Header-------------
header <- dashboardHeader(
title = "My Dashboard")
##Dashboard Sidebar----------------
sidebar <- dashboardSidebar(
sidebarMenu(
menuItem("Dashboard",tabName = "dashboard",
menuSubItem('Applicants',
tabName = 'applicants',
icon = icon("user", lib = "glyphicon")),
menuSubItem('Demographics',
tabName = 'demographics',
icon = icon("globe"))
),
menuItem("Job Positions", tabName = "jobposition",
menuSubItem('Associate',
tabName = 'associate',
icon = icon('address-card'))
)
)
)
##Dashboard Sidebar----------------
sidebar <- dashboardSidebar(
sidebarMenu(
menuItem("Dashboard",tabName = "dashboard",
menuSubItem('Applicants',
tabName = 'applicants',
icon = icon("user", lib = "glyphicon")),
menuSubItem('Demographics',
tabName = 'demographics',
icon = icon("globe"))
),
menuItem("Job Positions", tabName = "jobposition",
menuSubItem('Associate',
tabName = 'associate',
icon = icon('address-card'))
)
)
)
##Dashboard Body-------------------
body <- dashboardBody(
tabItems(
# Dashboard Tab Content
tabItem(tabName = "applicants",
fluidRow(
#Requires Attention Value Box
valueBoxOutput("attentionbox"),
#Applicant to Hire Avg TIme
valueBoxOutput("hireAvgTime"),
#Proportion of Women
valueBoxOutput("WomenPercent"))
,
fluidRow(
column(width = 12,
#Applicant Stage Plot
box(
title = ("Applicant Stages"),
status = "warning",
plotlyOutput("stageplot")
),
#Avg Skill Score Plot
box(
title = ("Average Skill Score"),
status = "warning",
plotlyOutput("AvgSkillScore")
))
)
),
tabItem(tabname = 'demographics',
fluidRow(
tabBox(
title = "",
id = "tabset1", height = "250px",
tabPanel("Gender", plot_ly(masterFemale, x = ~Stage, y = ~Female, type = 'bar', name = 'Female', hoverinfo = 'y') %>%
add_trace(y = masterFemale$Male,
name = 'Male',
hoverinfo = 'y') %>%
layout(
yaxis = list(title = 'Number of Applicants'),
barmode = 'group',
margin = list(b = 170)) %>%
config(displayModeBar = F)),
tabPanel("Country", plot_ly(masterCan, x = ~Stage, y = ~CAN, type = 'bar', name = 'CAN', hoverinfo = 'y') %>%
add_trace(y = ~US, name = 'US', hoverinfo = 'y') %>%
layout(
yaxis = list(title = 'Number of Applicants'),
barmode = 'group',
margin = list(b = 170)) %>%
config(displayModeBar = F)) #,
#tabPanel("Education")
))
),
# Associate Tab Content
tabItem(tabName = "associate",
fluidPage(
box(title = "Card Information", height = 300, "Text"),
#Main Box for Candidate
uiOutput("candidates")
)
)
)
)
ui <- dashboardPage(
skin = "yellow",
header,
sidebar,
body
)
shinyApp(ui, server)
在添加 menuSubitems 之前,其余代码和绘图工作正常。在我添加tabItem(tabname = 'demographics' 之后,它停止工作并且弹出了这个错误。任何帮助将不胜感激,谢谢!
【问题讨论】:
-
如果我从标签中删除
plot_ly,所有的工作都对我有用(因为你没有提供任何数据,所以我把它注释掉了) -
嘿,非常感谢您的提示!你对我如何在仍然使用 tabBoxes 的同时将 plotly 代码移动到服务器有什么建议吗?
-
我猜它可能是您的
plotly代码,我需要一些masterFemale和masterCan的示例数据来完全重现问题 -
@PorkChop 感谢您尝试与我一起解决这个问题。我在问题的顶部添加了一些示例数据。如果有任何问题请告诉我
标签: shiny shinydashboard