R/categorize.R

Defines functions categorize

Documented in categorize

categorize <-
function(dat, threshold) {

  threshold[length(threshold) + 1] = max(dat, na.rm=TRUE) + 1

  new = rep(NA, length(dat))
  for (i in 1:length(threshold))
    new[is.na(new) & dat < threshold[i]] = i

  return(new)
}

Try the nricens package in your browser

Any scripts or data that you put into this service are public.

nricens documentation built on May 2, 2019, 6:01 a.m.