Skip to content

hot_to_r fails to copy date data #427

@trentbaur

Description

@trentbaur

I've recently upgraded my setup to

  • R 4.3.0
  • rhandsontable 0.3.8

An existing rhandsontable app was failing when trying to copy the date column, returning NA instead of the date. I receive the following warning:

Warning in as.character.POSIXt(as.POSIXlt(x), ...) :
as.character(td, ..) no longer obeys a 'format' argument; use format(td, ..) ?

I built an example ShinyApp to reproduce the issue:

library(shiny)
library(rhandsontable)

ui <- fluidPage(
    titlePanel("rhandsontable Example"),
    
    sidebarLayout(
        sidebarPanel(
            actionButton("copyButton", "Copy Data")
        ),
        
        mainPanel(
            rHandsontableOutput("myTable"),
            textOutput("copiedData")
        )
    )
)

server <- function(input, output) {
    
    # Create initial data for the rhandsontable object
    initialData <- data.frame(
        Name = c("John", "Jane", "Mark"),
        Age = c(25, 30, 35),
        Date = as.Date(c("2022-01-01", "2022-02-01", "2022-03-01"))
    )
    
    # Render the rhandsontable object
    output$myTable <- renderRHandsontable({
        rhandsontable(initialData)
    })
    
    # Copy the data from the rhandsontable object and display it in a text field
    observeEvent(input$copyButton, {
        copiedData <- hot_to_r(input$myTable)
        output$copiedData <- renderText({
            paste("Copied Data:", paste(copiedData, collapse = ", "))
        })
    })
}

shinyApp(ui, server)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions