Data Science Desktop Survival Guide
by Graham Williams |
|||||
Naming Functions |
20201102
Preferred
build_cyc(num_frames=10)
Discouraged |
build_cyc(num.frames=10)
build_cyc(numFrames=10)
Keep variable and function names shorter but self explanatory. A long variable or function name is problematic with layout and similar names are hard to tell apart. Single letter names like x and y are often used within functions and facilitate understanding, particularly for mathematically oriented functions but should otherwise be avoided. l Preferred |
# Perform addition.
add_squares <- function(x, y) { return(x^2 + y^2) }
Discouraged |
# Perform addition.
add_squares <- function(first_argument, second_argument) { return(first_argument^2 + second_argument^2) }
|