I'm getting "Error in charToDate(x) : character string is not in a standard unambiguous format

I want to make a column in my data frame have Date format.

Please how do I resolve this?

Thanks in anticipation

You do not show what format your dates are in, so I cannot give exact advice. Here are two examples of changing characters in the m/d/y format to dates.

DF <- data.frame(Date = c("12/3/2022","4/17/2022"))
DF$Date <- as.Date(DF$Date, format = "%m/%d/%Y")
DF
#>         Date
#> 1 2022-12-03
#> 2 2022-04-17

library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#> 
#>     date, intersect, setdiff, union
DF <- data.frame(Date = c("12/3/2022","4/17/2022"))
DF$Date <- mdy(DF$Date)
DF
#>         Date
#> 1 2022-12-03
#> 2 2022-04-17

Created on 2022-12-29 with reprex v2.0.2

Thanks very much @FJCC . The format is YY/MM/DD

Either one of these methods should work:

DF <- data.frame(Date = c("22/12/3","22/4/17"))
DF$Date <- as.Date(DF$Date, format = "%y/%m/%d")
DF
        Date
1 2022-12-03
2 2022-04-17
library(lubridate)
DF <- data.frame(Date = c("22/12/3","22/4/17"))
DF$Date <- ymd(DF$Date)
DF
        Date
1 2022-12-03
2 2022-04-17

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.