【发布时间】:2021-08-24 23:55:52
【问题描述】:
我正在尝试使用表格的单个日期来做一个闪亮的值框。我的桌子是这样的:
Color<-c("blanco","blanco","gris","gris","blanco","gris","gris","gris","blanco","blanco","gris","blanco","gris","blanco","gris")
Tipo<-c("gato","gato","gato","perro","perro","perro","perro",
"buho","buho","buho","buho","tigre","tigre","tigre","tigre")
data<-data.frame(Color,Tipo)
在我的用户界面中
tabsetPanel(
position= "left",
tabPanel("Cancelaciones", icon = icon("window-close"),
fluidRow(
uiOutput("Box1")),
sidebarLayout(sidebarPanel(
uiOutput("SelectTipo")
),
mainPanel(
plotlyOutput("barplotx"),
dataTableOutput("summaryx")
) ) )
))
服务器
output$SelectTipo<-renderUI({
selectInput("SelectTipo", "Tipo",
data$Tipo, multiple = T, selected = TRUE)
})
df<-reactive({
data %>%
filter(Tipo %in% input$SelectTipo)
})
df1<-reactive({
df2<-df()
df2 %>%
count(Color)%>%
mutate(percent=round(((n/sum(n))*100), digits=2))%>%
arrange(desc(percent))>tmpx
names(tmpx)<- c("Evento","N","Porcentaje")
tmpx
})
valor<-df1[1,2] ##### <-----here is the line
output$Box1 <- renderUI({
valueBox(value = valor(), subtitle = "Valor", ##### <-and here
icon = icon("check-circle"),
color = "green")
})
我希望值框是第 1 列第 2 行中的值。
【问题讨论】:
-
我建议你先重新格式化你的代码。而且我注意到您正在尝试在自己的响应式中使用
df1,它不会输出任何内容。如果您可以定义df1反应式,那么您可以执行return(valor)。你不应该使用 valor() 因为它位于valueBox