I have a large df with many columns, here's a sample:
df <- data.frame(Quarter = c["Q4 2022", "Q4 2022", "Q1 2023", "Q1 2023"],
Date = c["2022-11-08", "2022-11-25", "02/09/2023", "03/15/2023"])
I want to change the "Date" column to a date field in the format YYYY-mm-dd (e.g. 2022-11-08). It's currently a character type.
I've tried the following:
df$`Date` <- as.Date(df$`Date`, "%Y-%m-%d")
but it ends up actually just dropping the last values in the column that are in the mm/dd/yyyy format and I end up with this:
Date = c["2022-11-08", "2022-11-25", NA, NA]
Anyone know why it's behaving this way?