I have an r dataset which has a list of timestamps like this: 2009-08-18 14:38:20 2010-08-10 14:58:25 etc
I want to extract the year but the Posixct doesn't have a years function unlike the months(t$timestamp)
Is there a way to get only 2009?
Use format:
x <- as.POSIXct(c("2009-08-18 14:38:20", "2010-08-10 14:58:25"))
format(x, "%Y")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With