[R] How to parse a really silly date with lubridate
Dr Eberhard Lisse
no@p@m @end|ng |rom ||@@e@NA
Wed Jul 13 15:40:43 CEST 2022
Hi,
I have data file which generated by an otherwise very nice (diabetes
log) app, but exports dates really silly.
After reading the enclosed mwe.csv into R like so
MWE <- read_delim('mwe.csv', delim = ';') %>%
select(Date) %>%
print()
this comes out as:
# A tibble: 2 × 1
Date
<chr>
1 9. Jul 2022 at 11:39
2 10. Jul 2022 at 01:58
No matter what I try I am not able to parse this inside R to get at
proper dates (I have loaded tidyverse and lubridate).
I can easily do somethig
csvq -d ';' -t '%e. %b %Y at %H:%i' \
'SELECT Date as oridate,
DATETIME_FORMAT(Date, "%Y-%m-%d %H:%m") AS date
FROM mwe'
+-----------------------+------------------+
| oridate | date |
+-----------------------+------------------+
| 9. Jul 2022 at 11:39 | 2022-07-09 11:07 |
| 10. Jul 2022 at 01:58 | 2022-07-10 01:07 |
+-----------------------+------------------+
and hence could easily do something like
csvq -d ';' -t '%e. %b %Y at %H:%i' \
'ALTER mwe
SET Date = DATETIME_FORMAT(Date, "%Y-%m-%d %H:%m")'
but would rather like to be able to do it inside R and would therefor
appreciate any advice in this regard.
greetings, el
--
To email me replace 'nospam' with 'el'
More information about the R-help
mailing list