我有一些葡萄牙语的日期,我想解析。
dts = c('19-mai-17', '26-mai-17', '2-jun-17', '9-jun-17', '16-jun-17')
lubridate::parse_date_time(dts, orders = "d-b-y", locale = "pt-BR")
但它只返回与英语重叠的日期,同时抛出一些警告:
[1] NA NA "2017-06-02 UTC" "2017-06-09 UTC" "2017-06-16 UTC"
Warning messages:
1: In Sys.setlocale("LC_TIME", locale) :
OS reports request to set locale to "pt-BR" cannot be honored
2: In Sys.setlocale("LC_TIME", locale) :
OS reports request to set locale to "pt-BR" cannot be honored
3: In Sys.setlocale("LC_TIME", locale) :
OS reports request to set locale to "pt-BR" cannot be honored
4: 2 failed to parse.
获得了locale
代码
运行Windows 7
答案 0 :(得分:1)
这可能只是使用正确的区域设置代码的问题。在MacOS上pt_BR
对我来说很好。事实证明,在Windows上,您可能想尝试Portuguese_Brazil.1252
。在任何情况下,使用
LC_TIME
区域设置
Sys.setlocale(category = "LC_TIME", locale = "pt_BR")