'How do I only keep the date and year for columns, and set to the right format?
I am cleaning a dataset for analysis. I don't know how to deal with these two columns of time/date data. How do I keep only the year/date and set it to the right format for analysis? They are currently treated as categorical data.

Solution 1:[1]
Something like this will help
df$date_last_pur <- as.Date(df$date_last_pur,format='%m/%d/%Y')
df$date_sign_up <- as.Date(df$date_sign_up,format='%m/%d/%Y')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | stefan_aus_hannover |
