【发布时间】:2020-05-12 17:09:53
【问题描述】:
我想用 dateInput() 做同样的事情。我将如何输出 dateInput() 中设置的默认日期来表示 verbatimTextOutput()?
代码:
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)
上面的代码还是不行,我在网上也找不到和这个匹配的答案。
【问题讨论】: