[R] Replacing dates with consecutive observations
Indrajit Sengupta
indra_calisto at yahoo.com
Thu Jan 22 10:20:40 CET 2009
Hi Alina,
You can always write a loop in R to do this:
# A function to shift values in an vector
shift = function(y) {
cnt = length(y) - 1
m=vector(mode = "numeric",length = cnt)
for (j in 1:cnt) {
m[j] = y[j+1]}
m
}
Regards,
Indrajit
________________________________
From: Alina Sheyman <alinashe at gmail.com>
To: r-help at r-project.org
Sent: Thursday, January 22, 2009 2:48:42 AM
Subject: [R] Replacing dates with consecutive observations
I am working with a list of dates and I would like to replace each date with
the one that comes after, ie. 1/1/07 will become 1/5/07, 1/5/07 will become
1/7/07, etc. The number of days between my dates always varies, so I can't
just increase each one by 5 days or so. Does anyone know of a way I can do
this in R?
thank you
[[alternative HTML version deleted]]
______________________________________________
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