Re: [R] adding 1 month to a date

2005-10-12 Thread bogdan romocea
Schwartz [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 11, 2005 10:16 PM To: t c Cc: r-help@stat.math.ethz.ch Subject: Re: [R] adding 1 month to a date On Tue, 2005-10-11 at 16:26 -0700, t c wrote: Within an R dataset, I have a date field called date_. (The dates are in the format -MM-DD

Re: [R] adding 1 month to a date

2005-10-12 Thread Prof Brian Ripley
: [R] adding 1 month to a date On Tue, 2005-10-11 at 16:26 -0700, t c wrote: Within an R dataset, I have a date field called date_. (The dates are in the format -MM-DD, e.g. 1995-12-01.) How can I add or subtract 1 month from this date, to get 1996-01-01 or 1995-11-01. There might

Re: [R] adding 1 month to a date

2005-10-12 Thread Marc Schwartz
this. -Original Message- From: Marc Schwartz [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 11, 2005 10:16 PM To: t c Cc: r-help@stat.math.ethz.ch Subject: Re: [R] adding 1 month to a date On Tue, 2005-10-11 at 16:26 -0700, t c wrote: Within an R dataset, I have a date

Re: [R] adding 1 month to a date

2005-10-12 Thread Jim Porzak
- From: Marc Schwartz [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 11, 2005 10:16 PM To: t c Cc: r-help@stat.math.ethz.ch Subject: Re: [R] adding 1 month to a date On Tue, 2005-10-11 at 16:26 -0700, t c wrote: Within an R dataset, I have a date field called date_

Re: [R] adding 1 month to a date

2005-10-12 Thread David Forrest
On Wed, 12 Oct 2005, Jim Porzak wrote: OTOH, seq(as.Date(2004-01-31), by = month, length = 14) [1] 2004-01-31 2004-03-02 2004-03-31 2004-05-01 2004-05-31 [6] 2004-07-01 2004-07-31 2004-08-31 2004-10-01 2004-10-31 [11] 2004-12-01 2004-12-31 2005-01-31 2005-03-03 I would prefer to

Re: [R] adding 1 month to a date

2005-10-12 Thread t c
Thanks. How do I se thsi to calculate a new variable (e.g.data$next_month) from an existing variable (e.g.Data$date_). I tried : data$next_month-seq(as.Date(data$date_), len = 2, by = month)[2], but get the following error message: Error in seq.Date(as.Date(data$date), len = 2, by = 1

Re: [R] adding 1 month to a date

2005-10-12 Thread t c
Thanks. How do I use this to calculate a new variable (e.g.data$next_month) from an existing variable (e.g.Data$date_). I tried : data$next_month-seq(as.Date(data$date_), len = 2, by = month)[2], but get the following error message: Error in seq.Date(as.Date(data$date), len = 2, by = 1

Re: [R] adding 1 month to a date

2005-10-12 Thread Gabor Grothendieck
To: t c Cc: r-help@stat.math.ethz.ch Subject: Re: [R] adding 1 month to a date On Tue, 2005-10-11 at 16:26 -0700, t c wrote: Within an R dataset, I have a date field called date_. (The dates are in the format -MM-DD, e.g. 1995-12-01.) How can I

Re: [R] adding 1 month to a date

2005-10-12 Thread Gabor Grothendieck
Try this: seq(as.Date(2005-01-15), len = 2, by = month)[2] or here is another approach: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/61570.html On 10/11/05, t c [EMAIL PROTECTED] wrote: Within an R dataset, I have a date field called date_. (The dates are in the format -MM-DD, e.g.

Re: [R] adding 1 month to a date

2005-10-12 Thread Gabor Grothendieck
Try this. Note that mapply strips off the class which is why we set up dd with the correct class and then just replaced the values. # test data d - as.Date(2005-1-1) + seq(0,90,30) # calculations, dd is the result next.month - function(x) seq(x, len = 2, by = months)[2] dd - d dd[] -

[R] adding 1 month to a date

2005-10-11 Thread t c
Within an R dataset, I have a date field called “date_”. (The dates are in the format “-MM-DD”, e.g. “1995-12-01”.) How can I add or subtract “1 month” from this date, to get “1996-01-01” or “ “1995-11-01”. - [[alternative

Re: [R] adding 1 month to a date

2005-10-11 Thread Marc Schwartz
On Tue, 2005-10-11 at 16:26 -0700, t c wrote: Within an R dataset, I have a date field called date_. (The dates are in the format -MM-DD, e.g. 1995-12-01.) How can I add or subtract 1 month from this date, to get 1996-01-01 or 1995-11-01. There might be an easier way to do this, but