r语言 - 如何在 dateInput() 中输出默认日期?



我想做同样的事情,但用dateInput((。我将如何输出 dateInput(( 中设置的默认日期来表示逐字文本输出((?

法典:

library(shiny)
library(shinythemes)
ui <- fluidPage(      
theme = shinytheme('slate'),
sidebarPanel(
selectInput(
'country',
'Select a Country',
c('Japan', 'China', 'USA'),
selected = 'Japan'
),
dateInput(
'date',
label = 'Select a Date',
value = as.character(as.Date('05/10/20', '%m/%d/%y')),
min = as.Date('01/22/20', '%m/%d/%y'),
max = as.Date('05/10/20', '%m/%d/%y'),
format = 'mm/dd/yy',
startview = 'month',
weekstart = 1
),
actionButton('resetBtn', 'Reset'),
actionButton('plotBtn', 'Plot', class = 'btn-primary')
),
mainPanel(
verbatimTextOutput('dateText', placeholder = TRUE)
)
)
server <- function(input, output) {
dateInput <- eventReactive(input$plotBtn, {
input$date
}, ignoreNULL = FALSE)
output$dateText <- renderText({
as.character(dateInput())
})
}

shinyApp(ui, server)

上面的代码仍然不起作用,我在网上找不到与此匹配的答案。

使用renderPrint而不是renderText

最新更新