[R] R: Adding 1 month to a dataframe column

2008-09-19 Thread ANGELO.LINARDI
It works great! Thank you so much Gabor Angelo Linardi -Messaggio originale- Da: Gabor Grothendieck [mailto:[EMAIL PROTECTED] Inviato: giovedì 18 settembre 2008 21.16 A: LINARDI ANGELO Cc: r-help@r-project.org Oggetto: Re: [R] Adding 1 month to a dataframe column Try this: # example

[R] Adding 1 month to a dataframe column

2008-09-18 Thread ANGELO.LINARDI
Dear R experts, I have a problem in modifying one column of a dataframe with a datatime format using a datetime operator. Here is my dataframe A: DATACONT PROVINCIA VALORE 1 2007-12-31MI 1 2 2007-12-31PV 2 3 2007-12-31NA 3 4 2007-12-31MI

Re: [R] Adding 1 month to a dataframe column

2008-09-18 Thread Gabor Grothendieck
Try this: # example data - Jan 31/00, Feb 29/00, Mar 31/00, ..., Dec 31/00 d - seq(as.Date(2000-02-01), by = month, length = 12) - 1 d # find beginning of next month nextmon - function(d) as.Date(cut(as.Date(cut(d, month)) + 32, month)) # add number of days from start of current