[R] sum with dates

R. Michael Weylandt michael.weylandt at gmail.com
Tue Dec 13 04:17:12 CET 2011


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 <rrasterr at gmail.com> wrote:
> How do I sum 15 years to my dataset?
>
> original dataset
>         dates        val
> 1    2001-01-12    1.2
> 2    2001-02-12    1.2
> 3    2001-03-12    1.2
>
> result
>         dates        val
> 1 2016-01-12 1.2
> 2    2016-02-12 1.2
> 3    2016-03-12 1.2
>
> ______________________________________________
> 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.



More information about the R-help mailing list