Re: [R] replace a for loop with lapply or relative

2010-02-04 Thread jim holtman
Have you considered using a different data structure: > # change the data structure > x <- data.frame( + type=rep(c('x1', 'x2', 'x3'), each=100), + high=c(d[,4], d[,5], d[,6]), + value=c(d[,1], d[,2], d[,3])) > head(x) type high value 1 x10 0.8936737 2 x10 -1.047298

[R] replace a for loop with lapply or relative

2010-02-04 Thread David Freedman
Dear helpers. I often need to make dichotomous variables out of continuous ones (yes, I realize the problems with throwing away much of the information), but I then like to check the min and max of each category. I have the following simple code to do this that cuts each variable (x1,x2,x3) at th