Re: [R] Generation of uniform random numbers

2010-09-03 Thread Dennis Murphy
Hi: Here's a slightly different approach, using both mapply() in base (a la David) and mlply() in plyr. My thought was to put the arguments together into a three column data frame; the names were chosen to correspond to the first three arguments of runif(): params <- data.frame(n = as.vector(rat

Re: [R] Generation of uniform random numbers

2010-09-03 Thread Gavin Simpson
Sarah, Here's a version using two nested loops: rate_number = matrix(c(5, 15, 60, 15, 5, 0, 20, 60, 20,0, 10, 20, 40, 20, 10), nrow = 5, ncol = 3) range_mat = matrix(c(6.25, 6.75, 7.25, 8.75, 9.25, 9.75, 8.5, 9, 9.5, 10.5, 11, 11.5, 4.25, 4.75, 5.25, 5.75, 6.25, 6.75), nrow = 6, ncol = 3) set.s

Re: [R] Generation of uniform random numbers

2010-09-03 Thread David Winsemius
On Sep 3, 2010, at 6:32 AM, Sarah Sanchez wrote: Dear R helpers I have following dataset rate_number = matrix(c(5, 15, 60, 15, 5, 0, 20, 60, 20,0, 10, 20, 40, 20, 10), nrow = 5, ncol = 3) range_mat = matrix(c(6.25, 6.75, 7.25, 8.75, 9.25, 9.75, 8.5, 9, 9.5, 10.5, 11, 11.5, 4.25, 4.7

Re: [R] Generation of uniform random numbers

2010-09-03 Thread jim holtman
Try this: > result <- list() # holds the numbers for each column > for (i in seq(ncol(rate_number))){ + ans <- NULL + for (j in seq(nrow(rate_number))){ + ans <- c(ans, runif(rate_number[j, i], range_mat[j, i], range_mat[j + 1, i])) + } + result[[i]] <- ans + } > result [[

[R] Generation of uniform random numbers

2010-09-03 Thread Sarah Sanchez
Dear R helpers I have following dataset rate_number = matrix(c(5, 15, 60, 15, 5, 0, 20, 60, 20,0, 10, 20, 40, 20, 10), nrow = 5, ncol = 3) range_mat = matrix(c(6.25, 6.75, 7.25, 8.75, 9.25, 9.75, 8.5, 9, 9.5, 10.5, 11, 11.5, 4.25, 4.75, 5.25, 5.75, 6.25, 6.75), nrow = 6, ncol = 3) > rate_