Defensive R Programming
Dr. Colin Gillespie
Jumping Rivers
Great results, can be achieved with small forces.
Sun Tzu, The Art of War
Filenames often contain multiple words
For example
cluster-analysis.R
load-survival-data.R
plot-residuals.R
Simple question. How should words be separated?
analysis clustering.R
analysis_clustering.R
analysis-clustering.R
Take a second and answer these two questions
Spaces in filenames and directories are a bad idea
file name.R
becomes file%20name.R
file name.R
- one spacefile name.R
- two spaces is hardThere are a few minor problems with underscores
file_name
as a single wordfile
won't work\w
treats _
as a characterThe same problems don't apply to dashes
Confession time:
Defensive R Programming