Is it any faster way to get the year from large data set (around 1GB) in R?
Currently I used data$year <- format(as.Date(data$pickup_datatime), "%Y")
to get the year, but it took very long time.
Is it any faster way to get the year from large data set (around 1GB) in R?
Currently I used data$year <- format(as.Date(data$pickup_datatime), "%Y")
to get the year, but it took very long time.
the lubridate
package has a built-in function to get the year from a date-like object. Here's the use for your case:
data$year <- lubridate::year(data$pickup_datatime)