# [R] selection simulation

vasquez j_ock21 at naver.com
Tue Mar 2 20:53:18 CET 2010

```Hi, I was having trouble developing a looping function in a selection
simulation that I'm trying to develop and I was hoping if someone could
help. Basically, I have a matrix with a random generated numbers
representing scores on the variables. The rows represent applicants and
columns represent the variables.

# Number of variables
p<-5

# Number of applicants
n_ap<-100

# Create random scores for the applicants across five variables
z<-rnorm(n_ap*p,0,1)

#Put z into a matrix
dim(z)<-c(n_ap,p)

#Rank applicant scores on variable X1
d1 <- rev(order(z[,1]))

#Rank applicant scores on variable X2
d2 <- rev(order(z[,2]))

#Rank applicant scores on variable X3
d3 <- rev(order(z[,3]))

#Rank applicant scores on variable X4
d4 <- rev(order(z[,4]))

#Rank applicant scores on variable X5
d5 <- rev(order(z[,5]))

pool <- cbind(d1,d2,d3,d4,d5)

Is there a way to specify a vector of selection ratio (e.g.
sr<-c(.10,.20,.30) ) and use this in a loop so that the function will
produce a matrix of applicants who will be selected when the selection ratio
is .10, .20, and .30?