I would like to adjust my table numbers. I would like to leave only two numbers after the comma, that is, instead of leaving 1.31231 it would be 1.31 and so on.
library(DT)
library(dplyr)
Test <- structure(list(date2 = structure(c(18808, 18808, 18809, 18810
), class = "Date"), Category = c("FDE", "ABC", "FDE", "ABC"),
coef1 = c(445.23231, 1.31231, 6.32323, 1.232),coef2 = c(8.3231, 3.3432, 1.3233, 6.3233)), row.names = c(NA, 4L), class = "data.frame")
Test<-Test%>%mutate(Sum = rowSums(across(3:last_col()), na.rm = TRUE))
Test <- Test %>% mutate(across(where(is.numeric), ~paste0('US $', .)))
> Test
date2 Category coef1 coef2 Sum
1 2021-06-30 FDE US $445.23231 US $8.3231 US $453.55541
2 2021-06-30 ABC US $1.31231 US $3.3432 US $4.65551
3 2021-07-01 FDE US $6.32323 US $1.3233 US $7.64653
4 2021-07-02 ABC US $1.232 US $6.3233 US $7.5553