Re: [R] sum with dates

2011-12-13 Thread Rolf Turner
On 13/12/11 15:39, Ana wrote: How do I sum 15 years to my dataset? You mean ``How do I ***add*** 15 years '' See the thread starting at http://r.789695.n4.nabble.com/Adding-a-year-to-existing-date-tp4078930p4078930.html cheers, Rolf Turner original dataset d

Re: [R] sum with dates

2011-12-12 Thread Jorge I Velez
Hi Ana, Check section 4 of http://www.jstatsoft.org/v40/i03/paper for more alternatives. HTH, Jorge.- On Mon, Dec 12, 2011 at 9:39 PM, Ana <> wrote: > How do I sum 15 years to my dataset? > > original dataset > datesval > 12001-01-121.2 > 22001-02-121.2 > 32

Re: [R] sum with dates

2011-12-12 Thread Enrico Schumann
If "adding x years to a date" means "increase the part of a date by x", then it should be easiest to manipulate the character representation of your date. dates <- as.Date(c("2001-01-12","2001-02-12","2001-03-12")) addYear <- function(d,addyears) { Y <- as.numeric(strftime(d, "%Y"))

Re: [R] sum with dates

2011-12-12 Thread R. Michael Weylandt
It depends how your dates are stored, but generally you can just add 365*15 to them. E.g., print(x <- Sys.Date()) print(x + 365*15) So for you, dataset$dates <- dataset$dates + 365*15 Michael On Mon, Dec 12, 2011 at 9:39 PM, Ana wrote: > How do I sum 15 years to my dataset? > > original datas

[R] sum with dates

2011-12-12 Thread Ana
How do I sum 15 years to my dataset? original dataset datesval 12001-01-121.2 22001-02-121.2 32001-03-121.2 result datesval 12016-01-121.2 22016-02-121.2 32016-03-121.2 _