Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Keep trailing zeros after rounding ==========================
- # - esp for printing in tables
- formatC( round(0.1025, 2), format = "f", digits = 2 )
- # Table formatting example with dplyr ===============================================
- # data
- df <- data.frame( original = c(0.00023, 0.237, 0.1025, 0.108) )
- # Add column with mutated, print-ready values
- df %>%
- dplyr::mutate( print = ifelse(original < 0.01, formatC(original, format = "e", digits = 1),
- formatC(round(original, 2), format = "f", digits = 2)) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement