I have a data frame (hf) that is all set up and the dates are working
fine - however I need to extract the months and hours (2 separate
columns) as numbers - however they are coming out as characters.
I have tried both the following:
hf50$hour= hf50$date
hf50$hour=format(hf50[hour],%H)
and
I have a data frame (hf) that is all set up and the dates are working
fine - however I need to extract the months and hours (2 separate
columns) as numbers - however they are coming out as characters.
I have tried both the following:
hf50$hour - hf50$date
hf50$hour - format(hf50[hour],%H)
Try
hf$hour - as.POSIXlt(hf$date)$hour
hf$month - as.POSIXlt(hf$date)$mon+1
To see why, use the man pages to study the structure of POSIXlt objects. Try:
tmp - strptime(20/2/06 11:16:16.683, %d/%m/%y %H:%M:%OS)
unclass(tmp)
For example:
tmp - strptime(20/2/06 11:16:16.683,
3 matches
Mail list logo