Re: [R] Dates to numeric in for loop

2017-11-14 Thread Jeff Newmiller
"Date" means "numeric with an attribute of class='Date' ", so what actually happened was that the for loop dropped the class attribute. In most cases using the seq_along() function lets you step through index values to extract values from your original vectors. In general, any S3 object will beh

[R] Dates to numeric in for loop

2017-11-14 Thread Mikkel Grum
Hi Can anyone explain why a date becomes numeric when you loop over a series of dates? > dt <- Sys.Date() > dt [1] "2017-11-14" > class(dt) [1] "Date" > dts <- dt - 1:0 > class(dts) [1] "Date" > > for (i in dts) { + print(i) + print(class(i)) + print(as.Date(i, "1970-01-01")) + pr