Data Science Desktop Survival Guide
by Graham Williams |
|||||
Comments |
20200105
#
to introduce ordinary comments and
separate comments from code with a single empty line before and
after the comment. Comments should be full sentences beginning with
a capital and ending with a full stop.
Preferred
# How many locations are represented in the dataset.
ds$location %>% unique() %>% length() # Identify variables that have a single value. ds[vars] %>% sapply(function(x) all(x == x[1L])) %>% which() -> constants
Sections might begin with all uppercase titles and subsections with initial capital titles. The last four dashes at the end of the comment are a section marker supported by . Other conventions are available for structuring a document and different environments support different conventions. Preferred |
# DATA WRANGLING —-
# Normalise Variable Names —- # Review the names of the dataset columns. names(ds) # Normalise variable names and confirm they are as expected. ds %<>% dplyr::rename_all(rattle::normVarNames) names(ds) # Wrangle weatherAUS —- # Convert the character variable 'date' to a Date data type. class(ds$date) ds$date %<>% lubridate::ymd() %>% as.Date() %T>% {class(.); print()}
|