R/bucketize.R

Defines functions bucketize

# preprocessr
#
# Function: bucketize()
#
# Description: A function to discretize a set of continuous data
#
# Author: Peter Xenopoulos
#
#

bucketize <- function(data, buckets) {
  if(class(data) != "numeric")
    warning("Data must be a vector of type numeric")
  
  # get # of bins, and length of data vector
  bins = c(1:buckets)
  data.len = length(data)
  
  # find how many extra slots the last bucket will have
  leftover = data.len %% buckets
  
  # find the width of a bucket
  width = floor(data.len/buckets)
  
  # initialize vector to return
  bucketized.vector <- ()
  
  
  for(i in 1:data.len) {
    bucketized.vector[i]
  }
  
}
peterxeno/preprocessr documentation built on May 25, 2019, 2:10 a.m.