R/left.R

Defines functions left

##' Take characters from the left-hand side of a string
##' 
##' @param x A vector of character strings
##' @param out_length The number of characters starting from the left
##' @author David Whiting, david.whiting@@publichealth.me.uk
##' @export
##' 

left <- function(x, out_length) {
  ret <- substring(x, 1, out_length)
  if (any(length(ret) < out_length))
    warning(paste("Some values are shorter than", out_length, "characters."))
  
  ret
}
daudi/phutils documentation built on May 5, 2019, 8:01 p.m.