Re: [R] Generating Sequence of Dates
> n = 2 > > > sort( rep( seq(as.Date("2000/1/1"), by="month", length.out=3), n ) ) > > [1] "2000-01-01" "2000-01-01" "2000-02-01" "2000-02-01" "2000-03-01" [6] "2000-03-01" On Sunday 20 November 2011 22:16:36 arunkumar wrote: > Hi. > > I need to generate a sequence of date, I need to generate date for a > period. Each date should be generated n times. > > E.g > > seq(as.Date("2000/1/1"), by="month", length.out=3) > > the output of this is "2000-01-01" "2000-02-01" "2000-03-01" > > But i need each date to be generated n times, if n =2 my output > > "2000-01-01" "2001-01-01" "2000-02-01" "2000-02-01" "2000-03-01" > "2000-03-01" > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Generating-Sequence-of-Dates-tp4090672p409 > 0672.html Sent from the R help mailing list archive at Nabble.com. > > __ > 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. __ 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.
Re: [R] Generating Sequence of Dates
Hi, Try rep(seq(as.Date("2000/1/1"), by="month", length.out=3), each = 2) and see ?rep for more info. HTH, Jorge.- On Mon, Nov 21, 2011 at 1:16 AM, arunkumar <> wrote: > Hi. > > I need to generate a sequence of date, I need to generate date for a > period. Each date should be generated n times. > > E.g > > seq(as.Date("2000/1/1"), by="month", length.out=3) > > the output of this is "2000-01-01" "2000-02-01" "2000-03-01" > > But i need each date to be generated n times, if n =2 my output > > "2000-01-01" "2001-01-01" "2000-02-01" "2000-02-01" "2000-03-01" > "2000-03-01" > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Generating-Sequence-of-Dates-tp4090672p4090672.html > Sent from the R help mailing list archive at Nabble.com. > > __ > 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.
[R] Generating Sequence of Dates
Hi. I need to generate a sequence of date, I need to generate date for a period. Each date should be generated n times. E.g seq(as.Date("2000/1/1"), by="month", length.out=3) the output of this is "2000-01-01" "2000-02-01" "2000-03-01" But i need each date to be generated n times, if n =2 my output "2000-01-01" "2001-01-01" "2000-02-01" "2000-02-01" "2000-03-01" "2000-03-01" -- View this message in context: http://r.789695.n4.nabble.com/Generating-Sequence-of-Dates-tp4090672p4090672.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] Generating sequence of dates
Thanks. Please expect more newbie questions!! Satish -Original Message- From: jim holtman [mailto:jholt...@gmail.com] Sent: Wednesday, October 28, 2009 7:05 AM To: Vadlamani, Satish {FLNA} Cc: R-help@r-project.org Subject: Re: [R] Generating sequence of dates try this: > current = as.Date("2009/10/25") > start <- seq(current, by='-1 week', length=2)[2] > seq(start, by='1 week', length=10) [1] "2009-10-18" "2009-10-25" "2009-11-01" "2009-11-08" "2009-11-15" "2009-11-22" "2009-11-29" "2009-12-06" "2009-12-13" [10] "2009-12-20" > On Wed, Oct 28, 2009 at 7:57 AM, Vadlamani, Satish {FLNA} wrote: > Hello All: > I have the following question > > # instantiate a date > current = as.Date("2009/10/25") > > #generate a sequence of dates in the future > future_dates = seq(current,by='1 week',length=53) > > Question: How to generate a sequence of past dates starting one week in the > past relative to the current date. Obviously, what I wrote below is not > correct. I think I can write a for loop and push each value into a vector. Is > this the best way? Thanks. > > Satish > > > past_dates = seq(current,by=-'1 week',length=156) > > __ > 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. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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.
Re: [R] Generating sequence of dates
try this: > current = as.Date("2009/10/25") > start <- seq(current, by='-1 week', length=2)[2] > seq(start, by='1 week', length=10) [1] "2009-10-18" "2009-10-25" "2009-11-01" "2009-11-08" "2009-11-15" "2009-11-22" "2009-11-29" "2009-12-06" "2009-12-13" [10] "2009-12-20" > On Wed, Oct 28, 2009 at 7:57 AM, Vadlamani, Satish {FLNA} wrote: > Hello All: > I have the following question > > # instantiate a date > current = as.Date("2009/10/25") > > #generate a sequence of dates in the future > future_dates = seq(current,by='1 week',length=53) > > Question: How to generate a sequence of past dates starting one week in the > past relative to the current date. Obviously, what I wrote below is not > correct. I think I can write a for loop and push each value into a vector. Is > this the best way? Thanks. > > Satish > > > past_dates = seq(current,by=-'1 week',length=156) > > __ > 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. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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.
[R] Generating sequence of dates
Hello All: I have the following question # instantiate a date current = as.Date("2009/10/25") #generate a sequence of dates in the future future_dates = seq(current,by='1 week',length=53) Question: How to generate a sequence of past dates starting one week in the past relative to the current date. Obviously, what I wrote below is not correct. I think I can write a for loop and push each value into a vector. Is this the best way? Thanks. Satish past_dates = seq(current,by=-'1 week',length=156) __ 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.