10.35 Wind Directions

20180723 The three wind direction variables () are also identified as character. We review the distribution of values here with dplyr::select() identifying any variable that tidyr::contains() the string _dir and then build a base::table() over those variables.

# Review the distribution of observations across levels.

ds %>%
  select(contains("_dir")) %>%
  sapply(table)
##     wind_gust_dir wind_dir_9am wind_dir_3pm
## N           11908        15053        11362
## NNE          8710        10723         8806
## NE           9434        10058        10950
## ENE         10730        10359        10357
## E           12007        12159        10906
## ESE          9850        10392        11179
## SE          12240        12320        13903
## SSE         11840        11924        11979
## S           11937        11313        12711
## SSW         11739        10072        10732
## SW          11604        10985        12005
## WSW         11970         9040        12571
## W           13030        10934        13283
## WNW         10786         9826        11675
## NW          10516        11309        11097
## NNW          8653        10226        10186

Observe all 16 compass directions are represented and it would make sense to convert this into a factor. Notice that the directions are in alphabetic order and conversion to factor will retain that. Instead we can construct an ordered factor to capture the compass order (from N, NNE, to NW and NNW). We note the ordering of the directions here.

# Levels of wind direction are ordered compas directions.

compass <- c("N", "NNE", "NE", "ENE",
             "E", "ESE", "SE", "SSE",
             "S", "SSW", "SW", "WSW",
             "W", "WNW", "NW", "NNW")


Your donation will support ongoing development and give you access to the PDF version of the book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 1995-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0.