[R] Binning Question
Noah Silverman
noah at smartmediacorp.com
Tue Apr 13 07:02:14 CEST 2010
David,
That helps me a lot. Thanks!!!
-N
On 4/12/10 9:06 PM, David Winsemius wrote:
> dat <- as.data.frame(matrix( rnorm(200), 100 , 2)) # bivariate normal
> n=100
>
> ab <- matrix( c(-5,-5,5,5), 2, 2) # interval [-5,5) x [-5,5)
> nbin <- c( 20, 20) # 400 bins
> bins <- bin2(dat, ab, nbin) # bin counts,ab,nskip
>
> dat$r1.cat <- cut(dat[,1], breaks=seq(ab[1,1], ab[1,2],
> length.out=nbin[1]+1 ) )
> dat$r2.cat <- cut(dat[,2], breaks=seq(ab[1,1], ab[1,2],
> length.out=nbin[1]+1))
> dat$bicat <- with(dat, paste( as.numeric(r1.cat), as.numeric(r2.cat),
> sep="."))
That's great, however something isn't coming out right.
I pasted your code into R and it looks like I'm getting different
numbers bicat. Should
More information about the R-help
mailing list