Using format() in R to convert numeric value to scientific notation after rounding

A small snippet of my overall code is to round a given vector to a specified number of decimal places. The rounded value is then converted to standard notation, e.g. "1.2e-01". The following does the rounding which works fine. values <- c(0.1234, 0.5678) dig <- 2 rounded_vals <- round(values, dig) %>% str_trim() When I run… Read More Using format() in R to convert numeric value to scientific notation after rounding