On Oct 6, 2010, at 11:07 PM, Santosh Srinivas wrote:
Dear List,
I have a column of dates say:
test$date1 <- seq(19900511, to = 19900521)
Those aren't dates. (but if they were the methods should be the same)
I want the next column to have the number of days between each
subsequent
date i.e days between r(i+1) and r(i)
> test$date1[2:length(test$date1)] - test$date1[1:(length(test
$date1)-1)]
[1] 1 1 1 1 1 1 1 1 1 1
> test$diffdt <- c(NA, test$date1[2:length(test$date1)] - test
$date1[1:(length(test$date1)-1)])
--
David.
Any easy way to do this? (I've done it in a roundabout way but just
wondering if there is any way more than done a loop)
Thanks.
______________________________________________
R-help@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.
______________________________________________
R-help@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.