r - 使用 Shiny/R 渲染带有日期的数据表时出错
问题描述
我有个问题。当我渲染从 Google 电子表格(通过 DT::renderDataTable)构建的数据表(通过 dataTableOutput)时,日期渲染不正确。例如:在电子表格中保存 1997/11/05 - Shiny 渲染 1997/11/04。我能做些什么呢?谢谢。
这是我的代码:
library(shiny)
# Page
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
),
# Show a plot of the generated distribution
mainPanel(
# Clients
tabItem(
tabName = "clients",
width = 2000,
br(),
box(
h2("Clients"),
width = 2000,
style="height: 520px; display: block;
margin-right: 10px; bottom: 0; overflow-y: hidden;",
br(),
div(dataTableOutput("clients"),
style="overflow-x: scroll;
height: 500px; display: block;"))
)
)
))
# Server
server <- function(input, output, session) {
cdata <- reactive({
googlesheets4::read_sheet('link')
})
output$clients <- DT::renderDataTable(DT::datatable(
cdata(),
options = list(
initComplete = JS(
"function(settings, json) {",
"$(this.api().table().header()).css({'background-color': 'gold',
'color': 'black'});",
"}"),
pageLength = 5, header = TRUE, lengthChange = FALSE),
rownames= FALSE,) %>% formatDate(c(2,4), method = "toLocaleDateString")
)
}
# Run App
shinyApp(ui = ui, server = server)
解决方案
推荐阅读
- .htaccess - 将 apache .htaccess 重写 [B] 标志规则转换为 nginx 时遇到问题
- vba - 使用 sap gui 获取列的总数
- html - Django从表单上传图片
- reactjs - reactjs中history .push和navlink有什么区别
- influxdb - 在特定日期之后获取创建的测量值
- java - java.util.NoSuchElementException: None.get Spark SQL Exception while 从 Mysql 数据库查询并将结果写入 Hadoop
- sql - 如何解决此过程中的此 SQL 错误 (1604)?
- html - Magento 2 事务性电子邮件错误,版权修改
- vue.js - Vuex 状态更新中断 v-for 反应性
- laravel - 如何在 vuejs 指令中使用 Laravel Blade 语法?