[R] Help with changing date format in R
kr|@@|evdh @end|ng |rom gm@||@com
Wed Jan 20 17:08:33 CET 2021
I have a big database where one-third of the data is in a different date
format than the rest. I'll add an example table to show you.
| plot | observer | date |
| 1 | K | 31012020 |
| 2 | K | 07022020 |
| 3 | B | 01282020 |
| 4 | B | 01292020 |
So I have two different date formats; the first is in d m y while the other
one is in m d y.
My question is how can I change all the date data into the same format?
Preferably in dd/mm/yy. (31-01-2020)
I know I could use:
d$date <- as.Date(d$date, format = "%d%m%Y")
d$date <- as.Date(d$date, format = "%m%d%Y")
but I can only do one and then it doesn't work. Is there a way i can use
the first line for the date of observer K and the other line for the date
of observer B?
[[alternative HTML version deleted]]
More information about the R-help