Readable R code uses names that describe the role of each value rather than its position or temporary history.

Program

Play the script to choose a cleaned name and see how a readable label carries meaning.

clear_names.R
style_index <- 
raw_names <- c("Total Sales", "customer ID", "net-profit")
clean_names <- c("total_sales", "customer_id", "net_profit")
chosen <- clean_names[style_index]
label <- paste("name", chosen, sep = ":")
cat(label, "\n", sep = "")
style_index <- 
raw_names <- c("Total Sales", "customer ID", "net-profit")
clean_names <- c("total_sales", "customer_id", "net_profit")
chosen <- clean_names[style_index]
label <- paste("name", chosen, sep = ":")
cat(label, "\n", sep = "")
style_index <- 
raw_names <- c("Total Sales", "customer ID", "net-profit")
clean_names <- c("total_sales", "customer_id", "net_profit")
chosen <- clean_names[style_index]
label <- paste("name", chosen, sep = ":")
cat(label, "\n", sep = "")
descriptive names Names such as `total_sales` and `customer_id` describe what a value means.
consistent style Using one naming style makes a script easier to scan.
lookup The index selects one readable name from a small vector.