04. Finding help in R

R is self-documenting, meaning all the help you need can be found within the program. This means that there are no excuses for not having help in case your Internet is down!

In-browser help

To get a more interactive version of the help prompt from within your browser, you can use the help.start() function.

This help features allows you to browse through manuals and help pages of packages already installed.

> help.start() 
The interactive help browser that opens up when calling help.start().
The interactive help browser that opens up when calling help.start(). In RStudio, it opens up in the Help panel.

The help function

In RStudio

To find help on a particular function, use the help() function, with the name of the function within the parentheses.

> help(print)

You can also use the question mark symbol as a shortcut.

> ?print
The print manual page as it appears in RStudio.
The print manual page as it appears in RStudio.

On the Terminal (without RStudio)

Without RStudio, the man page will pop up within the console. The controls to navigate this page are simple. Here are the most basic controls to help you get started.

j
down
k
up
^+d
Page down
^+u
Page up
h
View more navigating commands
q
Quit
The help page on the print function.
The help page on the print function.

For any special characters, such as the + arithmetic function use quotation marks.

> help("+")
> ?"+"

Examples

Still lost trying to figure out what a function does? That's okay! R also provides examples per function to help you get started.

> example(seq)
seq> seq(0, 1, length.out = 11)
 [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
 
seq> seq(stats::rnorm(20)) # effectively 'along'
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
 
seq> seq(1, 9, by = 2)     # matches 'end'
[1] 1 3 5 7 9
 
seq> seq(1, 9, by = pi)    # stays below 'end'
[1] 1.000000 4.141593 7.283185
 
...

Here, we can see examples of the seq command, which gives sequence variations in numeric sequence.

Searching for the function

Let's say you need help solving a system of equations, but are not sure of which function to use. You may search R's available functions based on their descriptions with the help.search() function.

> help.search("solve system of equations")
Help files with alias or concept or title matching ‘solve system of
equations’ using fuzzy matching:
 
 
base::solve             Solve a System of Equations
 
 
Type '?PKG::FOO' to inspect entries 'PKG::FOO', or 'TYPE?PKG::FOO' for
entries like 'PKG::FOO-TYPE'.

You may also use ?? as a shortcut.

The words before the two colons is the package name (in this case base) that the function comes from.

Keyword searching with apropos

To run a keyword search, you may use apropos(). This will look through all functions containing some string.

> apropos("sum")
...
 [7] "colSums"                 "contr.sum"              
 [9] "cumsum"                  "format.summaryDefault"  
[11] "print.summary.table"     "print.summaryDefault"   
[13] "rowsum"                  "rowsum.data.frame"      
[15] "rowsum.default"          "rowSums"                
[17] "sum"                     "sumAndDouble"     
...

Learn to be a Pythonista!

Python Playground

Learn to be a Pythonista! Try Python

Python Playground is a collection of fun programming projects that will inspire you to new heights. You'll manipulate images, build simulations, and interact with hardware using Arduino & Raspberry Pi. With each project, you'll get familiarized with leveraging external libraries for specialized tasks, breaking problems into smaller, solvable pieces, and translating algorithms into code.

$ Check price
29.9529.95Amazon 4 logo(14+ reviews)

More Python resources

Take your Linux skills to the next level!

How Linux Works

Take your Linux skills to the next level! Try Linux & UNIX

In this completely revised second edition of the perennial best seller How Linux Works, author Brian Ward makes the concepts behind Linux internals accessible to anyone curious about the inner workings of the operating system. Inside, you'll find the kind of knowledge that normally comes from years of experience doing things the hard way.

$ Check price
39.9539.95Amazon 5 logo(114+ reviews)

More Linux & UNIX resources

Ad