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")) + print(class(as.Date(i, "1970-01-01"))) + } [1] 17483 [1] "numeric" [1] "2017-11-13" [1] "Date" [1] 17484 [1] "numeric" [1] "2017-11-14" [1] "Date" Why is this apparently not a bug? Are there other types that change type when looped over? Kind regards Mikkel _____________________________________________________ *Mikkel Grum* +44 7377337321 (mobile) mikkelgrum (Skype) [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.