Re: [R] Assigning factors probabilistically based on the value of another variable.

2010-03-28 Thread Economics Guy
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

Re: [R] Assigning factors probabilistically based on the value of another variable.

2010-03-28 Thread Charles C. Berry
On Sun, 28 Mar 2010, Economics Guy wrote: 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

[R] Assigning factors probabilistically based on the value of another variable.

2010-03-27 Thread Economics Guy
I am revising a program that I wrote when I was very new at R (2007ish), and while I have been able to write very nice and fast code for almost all of it, there is one issue that I cannot seem to do it in less than 40 ugly and computationally expensive lines. I have a data frame that contains one

Re: [R] Assigning factors probabilistically based on the value of another variable.

2010-03-27 Thread Charles C. Berry
On Sat, 27 Mar 2010, Economics Guy wrote: I am revising a program that I wrote when I was very new at R (2007ish), and while I have been able to write very nice and fast code for almost all of it, there is one issue that I cannot seem to do it in less than 40 ugly and computationally expensive