Documentation
Every function that ships with R, and every function provided by a package distributed through CRAN, must come with documentation (also called a “help file”). This documentation describing exactly what the function does, what arguments it accepts, and what default values have been defined for those arguments. No matter how long you work with R, you will still consult documentation files regularly. Even experienced R users read the help files for functions they’ve used hundreds of times, just to double check an argument name or default value.
Why Documentation Matters
By now, you’ve called quite a few R functions: mean(), round(), sum(), install.packages(), library(), and many more. Every one of those functions accepts specific arguments, in a specific order, and some of those arguments have default values that you’ve been relying on without necessarily realizing it.
Do: Run the code below, and compare the two results.
See: Notice that the second line still works, even though we only gave round() one input.
The second argument to round(), digits, has a default value predefined. R uses that default to set the digits value whenever you don’t specify your own. But how are you supposed to know that there’s a default value set for digits, or know what that value actually is? Well, that’s exactly the kind of problem that documentation solves.
Besides looking up default argument values, what’s one other reason you might want to check a function’s documentation before using that function?