[R] Random sequence of days?

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Wed Aug 20 08:15:18 CEST 2008


Lauri Nikkinen wrote:
> Dear list,
> 
> I tried to find a solution for this problem from the archives but
> couldn't find any. I would like sample sequence of ten days from
> vector d
> 
> d <- seq(as.Date("2007-02-12"), as.Date("2008-08-18"), by="days")
> 
> so that the days follow each other (sample(d, 10) is not the
> appropriate solution). Any ideas?

"Follow each other" is not clear to me.  Do you want 10 consecutive days?
(Pick a random day between the first and the last less ten, and then
extract the consecutive days.)  Do you want random days, but in
sorted order? (sample ten days and sort the result.)

-- 
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                       Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k



More information about the R-help mailing list