Re: [R] Simple rep() question duplicating times and dates.

From: John Kane <jrkrideau_at_yahoo.ca>
Date: Wed, 05 Nov 2008 07:30:31 -0800 (PST)


I don't have R on this machine to try it but it looks good to me. I had even got as far as seq() but completely missed the use of "each".

Thanks very much.

> From: Gustaf Rydevik <gustaf.rydevik_at_gmail.com>
> Subject: Re: [R] Simple rep() question duplicating times and dates.
> To: jrkrideau@yahoo.ca
> Cc: "R R-help" <r-help_at_stat.math.ethz.ch>
> Received: Wednesday, November 5, 2008, 10:14 AM
> On Wed, Nov 5, 2008 at 4:02 PM, John Kane

> <jrkrideau_at_yahoo.ca> wrote:
> >
> > I want to create a data.frame of time and date for a
> year. I started with the idea of simply producing two
> vectors (time and date)
> >
> > The first part ( time) is easy.
> > rep(1:24, 365)
> >
> > But how do I get a series of 24 dates for O1 January
> 2005 and repeat this to 31 December 2005.
> >
> > It should be easy but I don't see it.
> >
> > Thanks
>
>
> Hi John,
>
> ?Date leads you to (among other things) ?seq.Date.
>
> Something like this should work:
>
> time<-rep(1:24, 365)
> dates<-seq(as.Date("01012005",format="%d%m%Y"),as.Date("31122005",format="%d%m%Y"),by=1)
> TimeFrame<-data.frame(time)
> TimeFrame$dates<-rep(dates,each=24)
>
>
> Regards,
> Gustaf
> --
> Gustaf Rydevik, M.Sci.
> tel: +46(0)703 051 451
> address:Essingetorget 40,112 66 Stockholm, SE
> skype:gustaf_rydevik



R-help_at_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. Received on Wed 05 Nov 2008 - 15:33:43 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 05 Nov 2008 - 16:30:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive