Possibly not the absolutely most efficient answer, but this is probably an
answer nonetheless
(David, hope I'm not encouraging bad behavior by replying.)

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)



On Wed, Dec 7, 2011 at 10:20 AM, Mao Jianfeng <jianfeng....@gmail.com>wrote:

> Dear David,
>
> Thanks for your response and warnings.
>
> I will obey the rule and be a good citizen.
>
> Best,
> Jian-Feng,
>
>
> Because you have a poorly posted problem. As far as I can tell you have not
> yet responded constructively to the attempts at clarification of the
> problem. Cross-posting to this list after waiting only 4 hours with an
> identical problem is bad Rhelp behavior.  You should use the interactive
> facilities at SO and better respect the efforts already being extended on
> your behalf.
>
>
>
>
> >
> >
> >
> >> I expect to hearing your helps/advice/directions in email or response in
> >> stackoverflow webpage. Thanks a lot in advance.
> >>
> >> Best wishes,
> >>
> >> Jian-Feng,
> >>
> >>
> >> I describe my question using the following dummy.
> >>
> >> ##############################
> >>
> >> # (1) the data (integer space consist of integer intervals defined by
> >> their
> >> begin and end) I have,
> >>
> >> integer.space <- data.frame(begin=c(1,5,6,15,**31,51,102),
> >> end=c(7,9,13,21,49,52,109))
> >>
> >>
> >> ##############################**#######
> >>
> >> # (2) what I want is to select the consequent integer intervals with
> >> # intra-length of 3 and inter-length of 2. and output the selected
> >> # intervals as begin and end. In this selection, I would like to select
> >> # more integer intervals as most as it could be.
> >> # the following are intervals I expected to be selected from the dummy
> >> data
> >>
> >> begin,end
> >> 1,3
> >> 6,8
> >> 11,13
> >> 16,18
> >> 31,33
> >> 36,38
> >> 41,43
> >> 46,48
> >> 102,105
> >>
> >
> > Last item does NOT have length of 3. Why have you not responded to this
> > observation on SO? And why would there not also be another line in the
> > sequence after 102,104 that would be 106,108? My suggestion would be to
> go
> > back to SO and be a better citizen.
> >
> >
> >>        [[alternative HTML version deleted]]
> >>
> >
> > Posting in HTML is also  bad citizenship on R-help.
> >
> >
> >> ______________________________**________________
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/**listinfo/r-help<
> https://stat.ethz.ch/mailman/listinfo/r-help>
> >> PLEASE do read the posting guide http://www.R-project.org/**
> >> posting-guide.html <http://www.R-project.org/posting-guide.html>
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> > David Winsemius, MD
> > West Hartford, CT
> >
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to