Why does iterating through a Date
or POSIXct
object result in numeric
? For example:
test = as.Date("2009-01-01")
print( class( test ) )
# [1] "Date"
for ( day in test )
{
print( class( day ) )
}
# [1] "numeric"
The same thing happens with POSIXct
:
test = as.POSIXct("2009-01-01")
print( class( test ) )
# [1] "POSIXct" "POSIXt"
for ( day in test )
{
print( class( day ) )
}
# [1] "numeric"
for(d in as.list(test)) print(class(test))
– Delwinfor
do what virtually everyone really wants it to do with a (vector? list? whatever) of dates. – Ebullition