> It is really the same thing. One of many possibilities: > >> theFrame <- data.frame(theValues=runif(150,-10,10)) >> exact <- diag(15)[1+ (rank(theFrame$theValues)-1)%/%10,] >> not.so.exact <- diag(15)[1+ >> (rank(theFrame$theValues+runif(150,0,3))-1)%/%10,] > > If what you actually wanted was one factor with fifteen levels, just wrap > the subscript in the last assignment in factor() instead. > > HTH, > > Chuck
Thanks Chuck, this does what I asked for: theValues <- runif(150,-10,10) exact <- factor(1+(rank(theValues)-1)%/%100) Unfortunately, it looks like my example may have been too contrived for my actual program. In the solution that Chuck proposed he antisipated that I may not want the assignment of factor levels to be exact: notSoExact <- factor(1+(rank(theValues+runif(150,0,3)-1)%/%100) This is close to what I need. However, in the real program what I need to be able to do is precisely vary the degree of exactness in the assignment. So I need to be able to have the assignment range from completely random assignment to the exact assignment that "exact" above provides. Anyone think of a simple way to do this? Thanks Agan, That Economics Guy ______________________________________________ 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.