简体   繁体   English

如何解决错误“文件错误:无效的'description'参数?

[英]How to resolve error " Error in file : invalid 'description' argument?

I have written a Shiny code that has a dashboard with the following elements 我编写了一个Shiny代码,其中包含一个包含以下元素的仪表板

1) Side Bar Layout 2) On clicking Tab 'view', the main panel gets populated with tabset panel 3) On clicking 'table', two selectInput should be displayed where the sheet dropdown is dependent on Table dropdown. 1)侧栏布局2)单击选项卡“视图”时,将在主面板中填充选项卡集面板3)在单击“表”时,应显示两个selectInput,其中工作表下拉菜单取决于表下拉菜单。 The Datasets are read from xlsx files 从xlsx文件读取数据集

library(shinydashboard)
library(leaflet)
library(ggplot2)
library(DT)
library(openxlsx)

# -----------------------------------------------------------------------------
# Dashboard UI
# -----------------------------------------------------------------------------

dataset <- c("P1-Long-Term-Unemployment-Statistics","P1-OfficeSupplies")
ui <- dashboardPage(
  dashboardHeader(
    title = "Validation Tool"
  ),
  dashboardSidebar(
    sidebarMenu(
      menuItem("View Tables", tabName = "view", icon = icon("database")),
      menuItem("Append Data", tabName = "append", icon = icon("database")),
      menuItem("Update Table", tabName = "update", icon = icon("crosshairs")),
      menuItem("Construct Table", tabName = "construct", icon = icon("fire"))
    ),

    div(style = "padding-left: 15px;padding-right: 5px; padding-top: 40px;",
        p(class = "small", "Note : This validation tools automates the mainstream process involved in creating a Master data for detailed analysis ")
    )
  ),
  dashboardBody(
    tabItems(
      # Current location ------------------------------------------------------
      tabItem(tabName = "view",
              mainPanel(
                titlePanel(h2("Explore Datasets")),fluidRow(
                  column(8,
                         selectInput("table",
                                     "Table:",
                                     dataset)
                  ),
                  column(8,
                         uiOutput("sheets")
                  ),
                  DT::dataTableOutput("table")
                ),
        tabsetPanel(type="tab", 
                    tabPanel("Data"

                             ),
                    tabPanel("Summary"),
                    tabPanel("Plot")
      )
    )
  )
)
)
)
# -----------------------------------------------------------------------------
# Dashboard server code
# -----------------------------------------------------------------------------
server <- function(input, output) {


    file <- reactive({paste0("D:/Dataset/",input$table,".xlsx")})
    sheetNames <- reactive({getSheetNames(file)})


    output$sheets <- renderUI({
    selectInput("sheet","Sheet:",choices = sheetNames)
    })

    output$table <- DT::renderDataTable(DT::datatable({    
    data <- read.xlsx(file,sheet=as.numeric(input$sheet))
    data
     }))


}


shinyApp(ui, server)

But while implementing the above, I get the error (screenshot attached) 但是在实现上面的过程中,我得到了错误(附上截图)

"Error : Invalid 'description' argument" "Error : cannot coerce type 'closure' to vector of type 'list' “错误:无效的”描述“参数”“错误:无法将类型” closure“强制转换为类型” list“的向量

Please help resolving the issue 请协助解决问题

You have to call reactive values with parentheses ( file reactive value declared in line 62). 您必须使用括号来调用无功值(第62行中声明的file无功值)。 But there is a file() function in base R, so change this eg for my_file and call it with parentheses, eg: 但是在基数R中有一个file()函数,因此请更改此参数(例如, my_file并用括号将其调用,例如:

my_file <- reactive({paste0("D:/Dataset/",input$table,".xlsx")})
sheetNames <- reactive({getSheetNames(my_file())})

The below code works fine 下面的代码工作正常

server <- function(input, output) {

  my_file <- function(){  
  my_file <- paste0("D:/Dataset/",input$table,".xlsx")
  }

  sheetNames <- function(){
  sheetNames <- getSheetNames(my_file())
  }


    output$sheets <- renderUI({
    selectInput("sheet","Sheet:",choices = sheetNames())
    })

    output$table <- DT::renderDataTable(DT::datatable({    
    data <- read.xlsx(my_file(),sheet=as.character(input$sheet))
    data
    }))


}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 文件错误(描述 = xlsxFile):使用 lapply 时“描述”参数无效 - Error in file(description = xlsxFile) : invalid 'description' argument when using lapply R闪亮:文件错误(文件,“ rt”):无效的“描述”参数 - R shiny: Error in file(file, “rt”) : invalid 'description' argument 文件(文件,“rt”)中的错误:调用函数时“描述”参数无效 - Error in file(file, "rt") : invalid 'description' argument , when calling the function 文件中的错误(文件,ifelse(追加,“a”,“w”)):无效的“描述”参数 - Error in file(file, ifelse(append, “a”, “w”)) : invalid 'description' argument R Openxlsx 包(版本 4.2.2)-文件错误(描述 = xlsxFile):“描述”参数无效 - R Openxlsx package (version 4.2.2) - Error in file(description = xlsxFile) : invalid 'description' argument for(seq_along(data_file)中的i:file(file,“ rt”)中的错误:无效的&#39;description&#39;参数 - for(i in seq_along(data_file): Error in file(file, “rt”) : invalid 'description' argument gzfile(file,“ rb”)中的错误:无效的&#39;description&#39;参数调用自:gzfile(file,“ rb”) - Error in gzfile(file, “rb”) : invalid 'description' argument Called from: gzfile(file, “rb”) 文件错误(文件,“rt”):读取 csv 文件时“描述”参数无效 - Error in file(file, "rt") : invalid 'description' argument when reading csv files 文件错误(文件):运行时无效的“描述”参数 R 图库示例 - Error in file(file) : invalid 'description' argument when running R graph gallery example 文件错误(文件,“rt”):complete.cases 程序中的“描述”参数无效 - Error in file(file, "rt") : invalid 'description' argument in complete.cases program
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM