search for: index_g

Displaying 2 results from an estimated 2 matches for "index_g".

Did you mean: index_0
2010 Oct 13
2
vectorizing: selecting one record per group
...oup. I know how to do this with a for. For example: lets say I have the data: A=cbind(rnorm(100),runif(100),(rep(c(1,2,3,4,5),20))) Where the third column is the group variable. Then what I want is to select 5 observations. Each one taken randomly from each group. INDEX =NULL i=1 for(index_g in unique(A[,3])){ INDEX [i]=sample(which(A[,3]==index_g),1) i=i+1 } SEL=A[INDEX,] Is there a way to do this without a “for”? in other words is there a way to “vectorize” this? Thank you, Mauricio Romero Quantil S.A.S. Bogotá,Colombia www.quantil.com.co "It is fr...
2010 Oct 15
0
nomianl response model
...group. I know how to do this with a for. For example: lets say I have the data: A=cbind(rnorm(100),runif(100),(rep(c(1,2,3,4,5),20))) Where the third column is the group variable. Then what I want is to select 5 observations. Each one taken randomly from each group. INDEX =NULL i=1 for(index_g in unique(A[,3])){ INDEX [i]=sample(which(A[,3]==index_g),1) i=i+1 } SEL=A[INDEX,] Is there a way to do this without a for? in other words is there a way to vectorize this? Thank you, Mauricio Romero Quantil S.A.S. Bogota,Colombia www.quantil.com.co "It is from the ear...