On 16 November 2010 16:10, wangwallace <talentt...@gmail.com> wrote: > > Michael, I really appreciate your help. > > but I got the following error message when I wan trying to run the function > written by you: > > Error in out[i, ] <- apply(help[, c(grp1 + 1, grp2 + 5)], 2, sample, 1) : > number of items to replace is not a multiple of replacement length
Did the data.frame or matrix you were sampling have the same general form as the example you posted previously ? Can you give me a small example that causes the error ? > I am not quite sure why would this happen. > > As a novice of R, these functions are kinda complex for me. I am wondering > if it is doable without using loops like that. I wasn't sure exactly what you wanted so the function was meant to be general and easy to modify. It is often possible to use constructs other than loops in R, though that doesn't mean the code will always be either faster or clearer. But you'll need to describe your requirements in more precise terms (short, clear examples are good) for folks here to suggest methods. > > Again, thank you so much!!! No worries. If you can provide an example that generates the error we should be able to get further. Michael ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.