Dear Gene, Thanks a lot for your kindness.
> isp <- data.frame(begin=c(1,5,6,15,31,51,102), end=c(7,9,13,21,49,52,109)) > isp > ints = apply(isp, 1, function(x)seq(x[1],x[2])) > ints > ints = do.call(c, ints) > ints > ## option to fix if the regions are overlapping > ## and you don't want overlapping regions resampled > ints = unique(ints) > ## sample from ints > sample(ints, 5) > sample(ints, 5, replace=TRUE) I learned much from your code, such as the function do.call(). Could you please give me more helps on finding ways to sample consecutive integer interval? And you may reply me through here (http://stackoverflow.com/questions/8413990/selecting-integer-intervals-with-specific-intra-inter-length-from-random-integer/8421698#8421698). This question have attracted several responses, but still now no answer came out. I am still struggling with it. Best wishes, Jian-Feng, ______________________________________________ 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.