Could you help me adjust the formatRound
of the datatable
function. I would like to leave it like this: formatRound(c(3:last_col())
, ie until the last column, but it doesn't work, how can I adjust this, because I don't want to specify a value, for example, c(3:4)
.
library(DT)
Test <- structure(list(date2 = structure(c(18808, 18808, 18809, 18810
), class = "Date"), Category = c("FDE", "ABC", "FDE", "ABC"),
coef = c(4, 1, 6, 1)), row.names = c(NA, 4L), class = "data.frame")
Test<-Test %>% mutate(date2 = format(ymd(date2), "%d/%m/%Y"))%>%
mutate(SUM = rowSums(across(3:last_col()), na.rm = TRUE)) %>%
mutate(across(everything(), ~ replace_na(as.character(.), '-')))
z<-datatable (Test, options = list(columnDefs = list(list(className = 'dt-center', targets = "_all")),
paging =TRUE,searching = FALSE, pageLength = 10,dom = 'tip',scrollx=T),rownames = FALSE)%>%
formatRound(c(3:last_col()), digits=0)