rich-iannone / splitr

Use the HYSPLIT model from inside R and do more with it
Other
141 stars 60 forks source link

Issues with lubridate in function trajectory_read #38

Closed DesperationSoftware closed 5 years ago

DesperationSoftware commented 5 years ago

Dear Rich,

I'm fairly new to both R and GitHub so sorry if this is not the appropriate way of doing this. Nevertheless, I found a significant bug in running SplitR and thought that was a good idea to share.

At line 43 of trajectory_read the lubridate::ymd_h function fails in parsing the date_h_string unless the system locale is English/American.

On my Italian computer if I run the standard example of hysplit_trajectory, it returns a trajectory with only NAs in traj_dt and traj_dt_i and issues Warning: All formats failed to parse. No formats found. per every ymd_h call.

If I instead set my system locale to English/American with Sys.setlocale("LC_ALL","English_United States.1252") the function runs correctly and the columns are filled with date and times.

Apparently, unless the locale is English/American lubridate::ymd_h is not able to parse dates in the format "yyyy-mm-dd h".

Maybe it is possible to insert some kind of workaround in the code to maximize the portability of SplitR in systems with different locales?

Anyhow thank you for the great job!

rich-iannone commented 5 years ago

Thanks for creating this issue! I'll have a closer look at this soon and fix the date-parsing so that it's independent of the locale.

rich-iannone commented 5 years ago

The function has been completely rewritten and doesn’t contain any lubridate function calls now. Could you test and make sure it works for your locale? Closing this issue for now but will re-open the issue if the problem persists.