Skip to content

Instantly share code, notes, and snippets.

@gsk3
Created August 3, 2012 17:58
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 gsk3/3250007 to your computer and use it in GitHub Desktop.
Save gsk3/3250007 to your computer and use it in GitHub Desktop.
#' Obtain the fractional part of a numeric
#'
#' Takes a numeric vector and returns a vector of the numbers after the decimal
#' place
#'
#' @param vec A numeric vector of any length
#' @return A vector of the same length as the input vec containing only the decimal component.
#' @examples
#' x <- runif(100)
#' fpart(x)
#'
fpart = function(vec) {
ret = vec - as.integer(vec)
ret
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment