Skip to content

Instantly share code, notes, and snippets.

@kieranrcampbell
Created January 2, 2018 23:06
Show Gist options
  • Save kieranrcampbell/1ca124b962d3ad4e2c65cff529480c96 to your computer and use it in GitHub Desktop.
Save kieranrcampbell/1ca124b962d3ad4e2c65cff529480c96 to your computer and use it in GitHub Desktop.
#' These functions round an input string 'x' to a desired
#' number of decimal places
round1 <- function(x) format(round(x, 1), nsmall = 1)
round2 <- function(x) format(round(x, 2), nsmall = 2)
roundn <- function(x, n = 2) format(round(x, n), nsmall = n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment