Re: [R] Format dates issues with R

2021-12-14 Thread Luigi Marongiu
Got it, thanks! On Tue, Dec 14, 2021 at 11:59 AM Ivan Krylov wrote: > > On Tue, 14 Dec 2021 11:54:08 +0100 > Luigi Marongiu wrote: > > > "9/29/2021" > > > format = "%d/%m/%y" > > > Why the conversion did not work? > > The according to the format, the date above is 9th of month No. 29 in > the ye

Re: [R] Format dates issues with R

2021-12-14 Thread Micha Silver
On 14/12/2021 12:54, Luigi Marongiu wrote: Hello, I have these kind of dates: ``` ori[[n[3]]] they look to me as month, date, year so I formatted them as: ``` Looks like that to me also. as.Date(ori[[n[3]]], format = "%D") # or: as.Date(ori[[n[3]]], format = "%d/%m/%y") But you form

Re: [R] Format dates issues with R

2021-12-14 Thread Ivan Krylov
On Tue, 14 Dec 2021 11:54:08 +0100 Luigi Marongiu wrote: > "9/29/2021" > format = "%d/%m/%y" > Why the conversion did not work? The according to the format, the date above is 9th of month No. 29 in the year 2020, followed by junk characters "21". Swap %m and %d to make them follow the actual o

Re: [R] Format dates issues with R

2021-12-14 Thread Ivan Calandra
Dear Luigi, Quickly, I spot two problems: 1) "09/20/2021" can only be month/day/year (and not day/month/year as you specified). 2) The year is given with century, so it should be upper case Y So as.Date(ori[[n[3]]], format = "%m/%d/%Y") should work. HTH, Ivan -- Dr. Ivan Calandra Imaging lab

[R] Format dates issues with R

2021-12-14 Thread Luigi Marongiu
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"