8.5 Identify Numeric Variables

We identify the numeric variables of a dataset by purrr::map()ing the function base::is.numeric() to find base::which() are numeric. Their names are stored into the variable numc.

# Note which variables are numeric.

vars %>%
  extract(ds, .) %>%
  sapply(is.numeric) %>% 
  which() %>%
  names() %T>%
  print() ->
##  [1] "risk_mm"         "temp_3pm"        "temp_9am"        "cloud_3pm"      
##  [5] "cloud_9am"       "pressure_3pm"    "pressure_9am"    "humidity_3pm"   
##  [9] "humidity_9am"    "wind_speed_3pm"  "wind_speed_9am"  "wind_gust_speed"
## [13] "sunshine"        "evaporation"     "rainfall"        "max_temp"       
## [17] "min_temp"

Your donation will support ongoing availability and give you access to the PDF version of this 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-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0