r - 闪亮的显示数字而不是日期
问题描述
我正在尝试用 Shiny 显示一个表格,但是我在以正确的格式显示日期时遇到了问题。这是我正在处理的一个例子:
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)
解决方案
如果您更改线路,它似乎有效:
selected <- as.Date('2000-01-01', "%Y-%m-%d")
到:
selected <- format(as.Date('2000-01-01'), "%Y-%m-%d")
推荐阅读
- java - JAR 没有找到主清单,即使在 XML 中声明它也是如此
- java - 使用 PoolingHttpClientConnectionManager 获取重用连接的统计信息
- sequelize.js - 关联模型的 Sequelize 排序不起作用
- c# - 通过查找表左外连接两个表
- php - 在 WooCommerce 中为特定邮政编码设置最低订购量
- javascript - 如何在 vue 3 中不触发 @update:modelValue 的情况下将 ref 设置为 ajax 调用的值?
- python - Python Boto3 分页错误:“PageIterator”对象不可下标
- javascript - 用于绘图的 React UseEffect
- javascript - Brython:拒绝加载脚本....违反以下内容安全策略指令:“script-src 'self'
- swift - 使用 WebView 以 100% 的比例打开网站