Data Science Desktop Survival Guide
by Graham Williams |
|||||
Wind Directions |
20180723 The three wind direction variables
(wind_gust_dir
, wind_dir_9am
, wind_dir_3pm
) are also identified as character. We review
the distribution of values here with dplyr::select()
identifying any variable that tidyselect::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)
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")
|