如何解决为什么我在 R Shiny 中的 renderUI 调用会产生“match.arg(position) 中的错误:'arg' 必须为 NULL 或字符向量”错误?
我正在构建一个 ShinyApp,它有 2 个标签,侧边栏略有不同。对于第一个侧边栏,我想要一个 selectInput,它具有数据集的名称,并且默认选择所有这些名称(不是通过使用像添加“全部”选项这样的解决方法,而是从字面上选择所有选项)。
最终,我希望可用的选项能够对用户的日期输入做出反应,但现在,我只想创建 renderUI 来填充我的选项。
当我尝试时,我收到以下错误:
Error in match.arg(position) : 'arg' must be NULL or a character vector
我尝试查找其他答案,例如 5 年前的 answer,但这对我的问题没有帮助。
output$project_filter <- renderUI({ #or the issue is likely here
shiny::req(input$file)
shiny::req(input$upload)
selectInput(inputId = "filter_by_project",label = "Filter by Project",choices = sort(unique(test$name)),multiple = TRUE,selected = sort(unique(test$name)))
library(shiny)
library(plotly)
library(shinyjs)
library(shinydashboard)
library(shinyWidgets)
library(dplyr)
library(htmltools)
dates_notes_text <- HTML("Dates are filterable by month and year,not day (e.g.,selecting 1 November 2021 or 25 November 2021 will yield the same result). <br><br>
To display only one month,have the start and end month be the same (e.g.,both November 2021). <br><br>
Visualizations on display up to 12 consecutive month.")
test <- tibble(name = c("Justin","Corey","Sibley"),april_2021 = c(10,100,101),may_2021 = c(1,4,7))
shinyApp(
ui = fluidPage(
tabsetPanel(
tabPanel("Project View",fluid = TRUE,sidebarLayout(
sidebarPanel(
h4("Upload utilization Report"),fileInput("file","Upload Tracker Data (.xlsx format only)",multiple = FALSE,accept = c(".xlsx")),actionButton(inputId = "upload",label = "Upload Data",style = "color: #FFFFFF; background-color: #CA001B; border_color: #CA001B"),br(),h4("Select Your Desired Filters"),div(id = "inputs",daterangeInput(
inputId = "date_filter",label = "Filter by Month and Year",start = today(),end = (today() + 90),min = "2021-04",max = NULL,format = "yyyy-mm",startview = "month",weekstart = 0,language = "en",separator = " to ",width = NULL,autoclose = TRUE
),actionButton(inputId = "date_notes",label = "Notes about Dates",br())),h3("Include/Exclude Specific Projects"),uIoUtput("project_filter"),#I think the issue is either here or in server (see note)
mainPanel(
)
)
),tabPanel("Resource View",sidebarLayout(
sidebarPanel(
h4("Upload utilization Report"),label = "Filter by Month",min = "2020-04",mainPanel(fluidRow(
)
)
)
)
)
),server = function(input,output) {
observeEvent(input$date_notes,{
showModal(modalDialog(dates_notes_text,title = "information about Selecting Dates"))
})
output$project_filter <- renderUI({ #or the issue is likely here
shiny::req(input$file)
shiny::req(input$upload)
selectInput(inputId = "filter_by_project",selected = sort(unique(test$name)))
})
}
)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。