ropensci-archive / bomrang

:warning: ARCHIVED :warning: Australian government Bureau of Meteorology (BOM) data client for R
Other
109 stars 26 forks source link

Refactor code to be more concise #40

Closed adamhsparks closed 7 years ago

adamhsparks commented 7 years ago

Some of the code could probably be refactored to be much shorter. One example is the series of checks for whether certain columns are in the data frame within the .get_obs function. Another example is the code to create xmlbulletin based on the state chosen in a couple of the functions, which could probably be shortened a good bit using the case_when function from dplyr. Although, in that second specific case, given that the number of states should stay the same in the future, I guess there probably shouldn't be any maintanance problems resulting from the current approach for that piece of code.

https://github.com/ropensci/onboarding/issues/121#issuecomment-315419598

adamhsparks commented 7 years ago

Code is refactored for state selection in get_ag_bulletin() and get_precis_forecast().

However, since get_ag_bulletin() checks for the existence of individual columns, it's not if else() statements, but several if() statements. I cannot see how this would work in a dplyr::case_when() situation.