R valueBox显示使用反应式功能从selectInput中选择的列的最大值

R valueBox显示使用反应式功能从selectInput中选择的列的最大值,r,shiny,shinydashboard,reactive,R,Shiny,Shinydashboard,Reactive,新到R闪亮。当我尝试使用反应式函数实现valueBox时,反应式函数通过基于用户选择的列名选择进行更改,然后我希望从所选列生成最大值。 由于找不到对象“Ordered_Product_Sales”而产生了一系列错误,尽管该对象显然无法应用非函数 这是我的密码 library(shinythemes) library(shiny) library(plotly) library(lubridate) library(shinydashboard) library(shinyWidgets) ui

新到R闪亮。当我尝试使用反应式函数实现valueBox时,反应式函数通过基于用户选择的列名选择进行更改,然后我希望从所选列生成最大值。 由于找不到对象“Ordered_Product_Sales”而产生了一系列错误,尽管该对象显然无法应用非函数

这是我的密码

library(shinythemes)
library(shiny)
library(plotly)
library(lubridate)
library(shinydashboard)
library(shinyWidgets)
ui <- dashboardPage(skin = "black", #theme = shinytheme("cyborg"),
dashboardHeader("Metric Tracker"),
dashboardSidebar(
        sidebarMenu(
          menuItem("Dashboard", tabName = "Dashboard", icon = icon("city"))))

dashboardBody(fluidRow(
tabItems(
    tabItem(tabName = "Dashboard",
box(width = 4,title = "Inputs", solidHeader = TRUE, status = "warning", selectInput("value", "1st Value to Track:" , choices =  c("Units_Ordered", "Buy_Box_Percentage", "Ordered_Product_Sales", "Session_Percentage","aov"), selected = "Ordered_Product_Sales", multiple = FALSE, selectize = TRUE)
valueBoxOutput("max"), valueBoxOutput("min", width = 3)      
      ),

server <- function(input, output){

g <- reactive({
  (input$value)
})

output$max <- renderValueBox({
#maxi <-  max(metricx2[,get(g())])
valueBox(maxi, subtitle = "Max")

库(shinythemes)
图书馆(闪亮)
图书馆(绘本)
图书馆(lubridate)
图书馆(shinydashboard)
图书馆(shinyWidgets)

ui您没有显示足够的代码让我看到问题所在。下面是一个简单的工作示例:

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
    dashboardHeader(title = "Dynamic boxes"),
    dashboardSidebar(
        selectInput('column', 'Column:', names(mtcars))
    ),
    dashboardBody(
            valueBoxOutput("vbox")
    )
)

server <- function(input, output) {
    output$vbox <- renderValueBox({
        valueBox(
            paste('Maximum of', input$column),
            max(mtcars[[input$column]])
        )
    })
}

shinyApp(ui, server)
库(闪亮)
图书馆(shinydashboard)

无论您是否需要其他数据,该ui都可以正常工作。非常感谢。