[R] Function in nested loop

2011-10-18 Thread Eekhout, I.
Hi all, I would like to run a function with several nested conditions, which are completely factorial. The input data (x1) has two different sample sizes, so: x1 <- dat1 x1 <- dat2 Then a can have 3 different values: a <- 0.15 a <- 0.35 a <- 0.50 Then b can have 2 different values: b <- data.matr

[R] Replace a for loop with a function

2011-09-19 Thread Eekhout, I.
Hi all, I would like to replace the for loop in the code below with a function to improve the speed and to make the script more efficient. The loop creates a vector of integers (x) with the probability of f for each integer. The length of f is variable, but sums to 1. I tried to use a function