On Tue, Jan 25, 2011 at 06:00:36AM -0800, vioravis wrote:
> 
> I am trying to do binning on three variables (3d binning). The bin boundaries
> are specified by the user separately for each variable. I used the bin2
> function in the 'ash' package for 2d binning that involves only two
> variables but didn't any package for similar binning with three variables.
> Are there any packages or codes available for 3d binning?? Thank you. 

Try the following, possibly with different breaks for each dimension.

  x <- matrix(rnorm(30000), ncol=3)
  breaks <- seq(-1, 1, length=5)
  xints <- data.frame(
  x1=cut(x[, 1], breaks=breaks),
  x2=cut(x[, 2], breaks=breaks),
  x3=cut(x[, 3], breaks=breaks))
  table(complete.cases(xints))
  xtabs(~ ., xints)

Hope this helps.

Petr Savicky.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to