I have the dataframe below and I create a kable out of this. How could I add commas between numbers every 3 digits?
Descs<-structure(list(Mean = c(NaN, 943330388, NaN, NaN, NaN, 543234645,
45831420, NaN, 27301292, 160818771), Median = c(NaN, 943330388,
NaN, NaN, NaN, 543234645, 45831420, NaN, 27301292, 160818771),
SD = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), MAD = c(NA,
0, NA, NA, NA, 0, 0, NA, 0, 0), MIN = c(NA, 943330388, NA,
NA, NA, 543234645, 45831420, NA, 27301292, 160818771), MAX = c(NA,
943330388, NA, NA, NA, 543234645, 45831420, NA, 27301292,
160818771), VAR = c(NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_
), RANGE = structure(c(NA, 943330388, NA, NA, NA, 543234645,
45831420, NA, 27301292, 160818771, NA, 943330388, NA, NA,
NA, 543234645, 45831420, NA, 27301292, 160818771), .Dim = c(10L,
2L)), QUANTILES = structure(c(NA, 943330388, NA, NA, NA,
543234645, 45831420, NA, 27301292, 160818771, NA, 943330388,
NA, NA, NA, 543234645, 45831420, NA, 27301292, 160818771), .Dim = c(10L,
2L), .Dimnames = list(NULL, c("25%", "75%")))), row.names = c("Comedy",
"Education", "Entertainment", "Film & Animation", "Gaming", "Howto & Style",
"Music", "People & Blogs", "Science & Technology", "Sports"), class = "data.frame")
library(kableExtra)
kable(Descs) %>%
kable_styling(
font_size = 15,
bootstrap_options = c("striped", "hover", "condensed")
)
Descs <- Descs %>% mutate(across(where(is.numeric), ~ formattable::comma(.x, big.mark = ",", format = "f", digits = 0)))
adn then usekable
on that object. The advantage is that it retains the columns asnumeric
while adding the format – Mullein