ropensci / weathercan

R package for downloading weather data from Environment and Climate Change Canada
https://docs.ropensci.org/weathercan
GNU General Public License v3.0
102 stars 29 forks source link

Convert factors in `stations` to characters #78

Closed boshek closed 4 years ago

boshek commented 4 years ago

I was wondering if you consider converting the factors in the stations internal dataframe to characters? I'm nit understand the rationale here. My thinking of factors is where there is order to a string. Those currently that have a factor class don't have that order so I am not sure the reason to keep them that. Happy to do this work but I wanted to check first.

library(weathercan)
stations
#> # A tibble: 26,283 x 14
#>    prov  station_name station_id climate_id WMO_id TC_id   lat   lon  elev
#>    <fct> <chr>        <fct>      <fct>      <fct>  <fct> <dbl> <dbl> <dbl>
#>  1 AB    DAYSLAND     1795       301AR54    <NA>   <NA>   52.9 -112.  689.
#>  2 AB    DAYSLAND     1795       301AR54    <NA>   <NA>   52.9 -112.  689.
#>  3 AB    DAYSLAND     1795       301AR54    <NA>   <NA>   52.9 -112.  689.
#>  4 AB    EDMONTON CO~ 1796       301BK03    <NA>   <NA>   53.6 -114.  671.
#>  5 AB    EDMONTON CO~ 1796       301BK03    <NA>   <NA>   53.6 -114.  671.
#>  6 AB    EDMONTON CO~ 1796       301BK03    <NA>   <NA>   53.6 -114.  671.
#>  7 AB    FLEET        1797       301B6L0    <NA>   <NA>   52.2 -112.  838.
#>  8 AB    FLEET        1797       301B6L0    <NA>   <NA>   52.2 -112.  838.
#>  9 AB    FLEET        1797       301B6L0    <NA>   <NA>   52.2 -112.  838.
#> 10 AB    GOLDEN VALL~ 1798       301B8LR    <NA>   <NA>   53.2 -110.  640 
#> # ... with 26,273 more rows, and 5 more variables: tz <chr>,
#> #   interval <chr>, start <int>, end <int>, normals <lgl>

Created on 2019-09-23 by the reprex package (v0.3.0)

steffilazerte commented 4 years ago

Factors are also useful when you want to keep track of what the 'options' or 'categories' are (not only orders), but in this case, I'm not sure they're very useful. Province is a factor only because I use factors and levels to rename them. More than happy to do away with them :)