Friday, June 20, 2014

Data analysis using R - R programming Tutorial ( Part 5 )

Documentation

R function documentation contains:
- A general description of the function
- A list and description of the function’s formal arguments and default
settings
- Details about the function
- A list and description of values returned by the function
- References
- An executable example





Sometimes the documentation is very complete and other times it is vague.
It is more of a quick reference and not intended for instruction.
Better educational resources are the R manuals, contributed manuals, and
FAQs available on the R website.
There are also mailing lists. You can search archived posts or post new
questions. Posting is not for the faint of heart. If you post, be sure to have
a thoughtful question and read the posting guide.


To look at the documentation for a specific function from a loaded package,
?function name
help(function name)
To look at the documentation of a symbol put quotations around the
symbol, i.e. ?“:”
To search the documentation of all installed packages for key words,
??"key words"
help.search("key words")
A list of functions with the corresponding package is returned,
package::function name
To run the example included with the documentation,
example(function name)
There are also demos included with the base system and some packages. To
see a complete list of demos in the base system, demo(). To run a particular
demo, demo("topic").

Example - Documentation

Suppose we need help with the linear regression function. If we know the
name of the function, lm, but have a question about the syntax,
?lm
On the other hand if we don’t know what function to use,
help.search("regression")
To execute the example include with lm,
example(lm)