这与我的另一篇文章有关,关于在我的shinyDashboard应用程序中添加新的fluidRow(conainting plot + selectInput)。
当我运行下面的代码时,我收到以下
Error in if (inline) { : argument is not interpretable as logical
我试图修改代码的编写方式,例如:删除逗号,但我找不到摆脱错误的方法。更重要的是,我认为这是导致无法产生额外流量的原因之一。
我感觉它与我的输入控件有关,但不知道是什么!
任何帮助都将不胜感激。
ui.r
ui <- dashboardPage(
skin = "red",
dashboardHeader(title = "iReport",
titleWidth = 500),
dashboardSidebar(),
dashboardBody(
tabItems(
# Tab for Dashboard
tabItem(tabName = "Dashboard"),
# Tab for Survey Analytics
tabItem(tabName = "Survey"),
#Tab for Enquiry Analytics
tabItem(tabName = "Enquiries"),
#Tab for Web Analytics
tabItem(tabName = "Metrics"),
#Tab for Twitter Analytics
tabItem(tabName = "Twitter")
),
# Row 1 objects
fluidRow(
# Value boxes
valueBox(
479,
"Total No. of Enquiries",
color = "green",
icon = icon("commenting")
),
valueBox(
1.7,
"Average response time",
color = "blue",
icon = icon("exchange")
),
valueBox(
"98%",
"Percentage satisfied customers",
color = "orange",
icon = icon("thumbs-up")
)
),
# Row 2 objects
fluidRow(box(
width = 12, plotlyOutput("Time_Ser", height = "400px")
)),
# Row 3 objects
fluidRow(
# Data visualisations 1
box(width = 5, plotlyOutput("Enq_Num", height = "500px")),
box(
width = 2,
h2("Control panel"),
dateRangeInput(
"date",
"Date:",
label = h4("Choose a time frame"),
start = "2017-05-02",
end = "2017-07-30",
min = "2017-05-02",
max = "2017-06-30",
startview = "2017-06-30"
),
selectInput(
"select",
"Select",
label = h4("Select a month"),
choices = c("May", "June")
),
radioButtons(
"area",
"Area",
label = h4("Response Time by Team"),
choices = list("PEU", "DAU", "MSU", "PRO", "MISC"),
selected = "PEU"
)),
box(width = 5, plotlyOutput("Response", height = "500px"))),
#Row 4 Objects
fluidRow(# Data visualisations 2
box(width = 5, plotlyOutput("Enq_Outcome")),
box(
width = 2,
selectInput(
"outcome",
"Outcome",
label = h4("Enquiry outcomes by output area"),
choices = list("Link", "Clarified", "CM", "Unavailable", "Referred")
)))))
server.r
server <- function(input, output) {
# Reactive date input for Tim_Ser
Time2 <- Time
reactiveTime <- reactive({
Time2 %>% filter(Date.received >= input$date[1] &
Date.received < input$date[2])})
# DATA
Numbers <-
data.frame(
May = c(73, 26, 23, 10, 23),
June = c(144, 28, 21, 20, 33),
areas = c("PEU", "MIG", "DAU", "MISC", "PRO")
)
Time <- CusTible %>% group_by(Date.received) %>% tally(sort = TRUE)
Time = Time[order(Time$Date.received), ]
Respond <-
data.frame(
DAU = c(32, 14, 8),
MIG = c(51, 7, 4),
MISC = c(42, 41, 3),
PEU = c(135, 16, 18),
PRO = c(32, 15, 2),
Days = c("1-2 Days", "3-4 Days", "5+ Days")
)
rownames(Respond) <- c("1-2 Days", "3-4 Days", "5+ Days")
Outcome <-
data.frame(
Area = c("DAU", "PEU", "PRO", "MSU", "MISC"),
CLAR = c(5, 23, 2, 2, 13),
LINK = c(45, 4, 23, 24, 18),
UNAV = c(1, 13, 15, 11, 12),
CM = c(8, 15, 3, 10, 2),
REF = c(26, 24, 11, 7, 12)
)
# OUTPUTS
output$Time_Ser <- renderPlotly({
Time_Ser <-
plot_ly(reactiveTime(),
x = Date.received,
y = n,
mode = "lines") %>%
layout(title = "Q3. Enquiries over Time")
})
output$Enq_Num <- renderPlotly({
selector <- switch(input$select,
"May" = Numbers$May,
"June" = Numbers$June)
Enq_Num <- plot_ly(
Numbers,
x = areas,
y = selector,
type = "bar",
color = areas
) %>%
layout(
title = "Q3. Enquiries by Output Team by Month",
xaxis = list(title = "Output Team", showgrid = F),
yaxis = list(title = "No. Enquiries")
)
})
output$Response <- renderPlotly({
if (is.null(input$area))
return()
area.select <- switch(
input$area,
"PEU" = Respond$PEU,
"DAU" = Respond$DAU,
"MSU" = Respond$MIG,
"PRO" = Respond$PRO,
"MISC" = Respond$MISC
)
Response <- plot_ly(
Respond,
labels = Days,
values = area.select,
type = "pie",
rotation = 180,
direction = "clockwise",
hole = 0.6
) %>%
layout(title = "Q3. Response Time")
})
output$Enq_Outcome <- renderPlotly({
enq.outcome <- switch(
input$outcome,
"Clarified" = Outcome$CLAR,
"Link" = Outcome$LINK,
"CM" = Outcome$CM,
"Unavailable" = Outcome$UNAV,
"Referred" = Outcome$REF
)
Enq_Outcome <- renderPlotly(
Outcome,
y = Area,
x = enq.outcome,
type = "bar",
colour = Area
)
})
}
shinyApp(ui, server)
答案 0 :(得分:0)
经过多次坚持和专家的大量帮助后,
我发现我的所有问题都归结为 radioButton()输入选择器:
我替换
radioButtons(
"area",
"Area",
label = h4("Response Time by Team"),
choices = list("PEU", "DAU", "MSU", "PRO", "MISC"),
selected = "PEU"
)),
带
selectInput(
"area",
"Area",
label = h4("Response Time by Team"),
choices = list("PEU", "DAU", "MSU", "PRO", "MISC"),
)),
代码工作正常,错误消息消失,新的plot和fluidRow集成到仪表板中。