timezone error reading csv

房东的猫 提交于 2020-05-15 10:40:07

问题


After googling for a couple of hours I have not found a solution to this problem. Basically when I run read_csv("some_file.csv") function from readr package I get the following error:

Error: Unknown TZ UTC

and csv is not read.

The only way I can read the CSV is this way:

read_csv("some_file.csv",locale=locale(tz="Australia/Sydney"))

Sydney being my timezone.

But I'd rather fix the error than work around it if possible. Does anybody know how to fix the UTC error permanently? E.g. Startup instructions? Ta.


回答1:


the locale input argument is set to default_locale(). When you print out the default_locale function, you can see that it read in the locale from options.

To set the locale permanently so that it is set every time you start R, you can add the following line to your ~PATH_TO_R~/etc/Rprofile.site

options(readr.default_locale=readr::locale(tz="Australia/Sydney"))

For temporary solution, just add this line at the top of your script



来源:https://stackoverflow.com/questions/42638145/timezone-error-reading-csv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!