[R] select integer intervals from a integer space
jianfeng.mao at gmail.com
Wed Dec 7 21:15:57 CET 2011
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))
> ints = apply(isp, 1, function(x)seq(x,x))
> ints = do.call(c, 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
And you may reply me through here
This question have attracted several responses, but still now no
answer came out.
I am still struggling with it.
More information about the R-help