I have character date format, November 17, 2021, and how can I convert it into the date format, 2021-11-17 in R? I have tried as.Date() but it returns an error. Thanks so much for your help.
x <- "November 17, 2021"
as.Date(x)
CodePudding user response:
Using the lubridate library, you can do:
Reprex
- Code
library(lubridate)
x <- "November 17, 2021"
mdy(x)
- Output
# "2021-11-17"

