'Using locale's date_format in readr
How do I correctly set locale's date_format to work with cols() from readr?
Instead of specifying the date format for every column:
df <- read_csv2(my_file,
col_types = cols(.default = '?',
my_date = col_date(format = '%d.%m.%Y')))
I want to specify it once. cols()'s documentation says:
col_date(format = "") [D]: with the locale's date_format.
so I tried:
locale(date_format = '%d.%m.%Y')
df <- read_csv2(my_file,
col_types = cols(.default = '?',
my_date = 'D'))
But this throws the warning (received with problems()):
expected: <chr> date in ISO8601
actual: <chr> 01.01.2000
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
