3
Can anyone explain why in for-loop
the objects Date
are converted to integer
?
In the code below I want to iterate on the dates but these are converted to integers.
> dates <- Sys.Date() + 1:10
> dates
[1] "2015-09-29" "2015-09-30" "2015-10-01" "2015-10-02" "2015-10-03" "2015-10-04" "2015-10-05" "2015-10-06" "2015-10-07" "2015-10-08"
> for (date in dates) print(date)
[1] 16707
[1] 16708
[1] 16709
[1] 16710
[1] 16711
[1] 16712
[1] 16713
[1] 16714
[1] 16715
[1] 16716
If I use a list it doesn’t happen.
> for (date in as.list(dates)) print(date)
[1] "2015-09-29"
[1] "2015-09-30"
[1] "2015-10-01"
[1] "2015-10-02"
[1] "2015-10-03"
[1] "2015-10-04"
[1] "2015-10-05"
[1] "2015-10-06"
[1] "2015-10-07"
[1] "2015-10-08"
Does anyone know why?