I am using rhandontable with checkboxes to capture the row selections. In the observeEvent, I use hot_to_r to capture the input table. But I get this error:
Called from: observe()
Browse[1]> hot_to_r(input$hot)
Error in as(d[[i]], colClasses[i]) :
no method or default for coercing “character” to “NA”
Here is my shiny code:
library(shiny) library(rhandsontable)
ui = shinyUI(fluidPage(
fluidRow(wellPanel(
rHandsontableOutput("hot"),
actionButton(inputId="enter",label="enter")
))
))
server=function(input,output){
output$hot=renderRHandsontable({
cs_list <- structure(list(id = c(2200L, 2199L, 2198L, 2197L, 2196L, 2194L,
2192L, 2191L, 2190L, 2182L), name = LETTERS[1:10], createdDate = structure(c(1686085982.446, 1686083874.989,
1686081629.669, 1686076846.466, 1686067053.29, 1686064540.23,
1686007128.569, 1686006010.05, 1686005209.098, 1685991901.098
), tzone = "America/Chicago", class = c("POSIXct", "POSIXt")),
createdBy = c("troggenkamp", "troggenkamp", "troggenkamp",
"troggenkamp", "ushrestha", "troggenkamp", "troggenkamp",
"troggenkamp", "troggenkamp", "troggenkamp"), bool = c(FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE
)), class = "data.frame", row.names = c(NA, -10L))
rhandsontable(cs_list, readOnly = FALSE)
})
observeEvent(input$enter, {
DF=hot_to_r(input$hot)
print(DF)
})
}
shinyApp(ui = ui, server = server)
It's a problem with the datetime column. You can do:
cs_list$createdDate <- format(cs_list$createdDate)
rhandsontable(cs_list)