[R] Format dates issues with R

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Tue Dec 14 11:54:08 CET 2021


Hello,
I have these kind of dates:
```
> ori[[n[3]]]
[1] "9/20/2021" "9/20/2021" "9/20/2021" "9/20/2021" "9/20/2021" "9/20/2021"
[7] "9/20/2021" "9/20/2021" "9/20/2021" "9/20/2021" "9/21/2021" "9/21/2021"
[13] "9/21/2021" "9/21/2021" "9/21/2021" "9/21/2021" "9/21/2021" "9/21/2021"
[19] "9/21/2021" "9/21/2021" "9/22/2021" "9/22/2021" "9/22/2021" "9/22/2021"
[25] "9/22/2021" "9/22/2021" "9/22/2021" "9/22/2021" "9/22/2021" "9/22/2021"
[31] "9/23/2021" "9/23/2021" "9/23/2021" "9/23/2021" "9/23/2021" "9/23/2021"
[37] "9/23/2021" "9/23/2021" "9/23/2021" "9/23/2021" "9/24/2021" "9/24/2021"
[43] "9/24/2021" "9/24/2021" "9/24/2021" "9/24/2021" "9/24/2021" "9/24/2021"
[49] "9/24/2021" "9/24/2021" "9/27/2021" "9/27/2021" "9/27/2021" "9/27/2021"
[55] "9/27/2021" "9/27/2021" "9/27/2021" "9/27/2021" "9/27/2021" "9/27/2021"
[61] "9/28/2021" "9/28/2021" "9/28/2021" "9/28/2021" "9/28/2021" "9/28/2021"
[67] "9/28/2021" "9/28/2021" "9/28/2021" "9/28/2021" "9/29/2021" "9/29/2021"
[73] "9/29/2021" "9/29/2021" "9/29/2021" "9/29/2021" "9/29/2021" "9/29/2021"
[79] "9/29/2021" "9/29/2021" "10/1/2021" "10/1/2021"
```
they look to me as month, date, year so I formatted them as:
```
> as.Date(ori[[n[3]]], format = "%D")
# or:  as.Date(ori[[n[3]]], format = "%d/%m/%y")
[1] NA           NA           NA           NA           NA
NA
[7] NA           NA           NA           NA           NA
NA
[13] NA           NA           NA           NA           NA
NA
[19] NA           NA           NA           NA           NA
NA
[25] NA           NA           NA           NA           NA
NA
[31] NA           NA           NA           NA           NA
NA
[37] NA           NA           NA           NA           NA
NA
[43] NA           NA           NA           NA           NA
NA
[49] NA           NA           NA           NA           NA
NA
[55] NA           NA           NA           NA           NA
NA
[61] NA           NA           NA           NA           NA
NA
[67] NA           NA           NA           NA           NA
NA
[73] NA           NA           NA           NA           NA
NA
[79] NA           NA           "2010-01-20" "2010-01-20"
```
Why the conversion did not work?
Thank you



More information about the R-help mailing list