R 显示数字而不是日期

R 显示数字而不是日期,r,date,shiny,R,Date,Shiny,我试图显示一个有光泽的表,但我有一个问题,以正确的格式显示日期。下面是我正在处理的一个示例: library(shiny) # Define UI for application that draws a histogram ui <- fluidPage( sidebarLayout( sidebarPanel( textInput("myfirstinput", "text1"), textInput("mysecondinput", "text

我试图显示一个有光泽的表,但我有一个问题,以正确的格式显示日期。下面是我正在处理的一个示例:

library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(
  sidebarLayout(

    sidebarPanel(
      textInput("myfirstinput", "text1"),
      textInput("mysecondinput", "text2"),
      actionButton("button", "An action button")
    ),
    mainPanel(
      tableOutput("table1")
    )
  )
)


# Define server logic required to draw a histogram
server <- function(input, output) {
  selected <- as.Date('2000-01-01', "%Y-%m-%d")
  selected <- as.list(selected)

  output$table1 <- renderTable(selected)

}

# Run the application 
shinyApp(ui = ui, server = server)
库(闪亮)
#为绘制直方图的应用程序定义UI

ui如果您更改行,它似乎会起作用:

  selected <- as.Date('2000-01-01', "%Y-%m-%d")

selected这也适用:)


选择如此简单。。。有时候,你会花上几个小时试图找到一个解决方案,而这最终很容易。非常感谢。
    selected <- format(as.Date('2000-01-01'), "%Y-%m-%d")

 selected <- as.character(as.Date('2000-01-01', "%Y-%m-%d"))