Skip to content

Instantly share code, notes, and snippets.

@mvaneggermond
Last active September 20, 2016 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvaneggermond/19d9ce95775021a21cbcc59faa7419d5 to your computer and use it in GitHub Desktop.
Save mvaneggermond/19d9ce95775021a21cbcc59faa7419d5 to your computer and use it in GitHub Desktop.
Round numeric values in a dataframe (R).
round_df <- function(df,digits)
{
nums <- vapply(df,is.numeric, FUN.VALUE = logical(1))
df[,nums] <- round(df[,nums],digits=digits)
(df)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment