I created a simple table using rhandsotable library and no matter how I format it, number always gets rounded down or up to closest integer. For example, if I type in 1.02, the result shown is 1. For 0.46, result shown is 0. I tried getting numbers to be double format, but issue persists. . Please kindly advise how to solve this issue. Thank you.
library(shiny)
library(rhandsontable)
GM <- data.frame(matrix(0.0, ncol = 5, nrow = 3))
col_names <- c("2015", "2016", "2017", "2018", "2019")
row_names <- c("Worst", "Base", "Best")
colnames(GM) <- col_names
rownames(GM) <- row_names
ui <- fluidPage(
titlePanel("GM"),
mainPanel(
rHandsontableOutput("GM"))
)
server <- function(input, output) {
v = reactiveValues()
observe({input$GM
if (!is.null(input$GM)) {
v$GM <- hot_to_r(input$GM)
print(v$GM) # to see if values get rounded down
} else {
v$GM <- GM
}
})
output$GM <- renderRHandsontable({
rhandsontable(v$GM, rowHeaderWidth = 150) %>%
hot_col("2015", format = "0,0.00%") %>%
hot_col("2016", format = "0,0.00%") %>%
hot_col("2017", format = "0,0.00%") %>%
hot_col("2018", format = "0,0.00%") %>%
hot_col("2019", format = "0,0.00%") %>%
hot_cols(colWidths = 100) %>%
hot_rows(rowHeights = 30)
})
}
shinyApp(ui = ui, server = server)