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"     
...

Take your Linux skills to the next level!

Command Line Kung Fu

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

Command Line Kung Fu is packed with dozens of tips and practical real-world examples. You won't find theoretical examples in this book. The examples demonstrate how to solve actual problems. The tactics are easy to find, too. Each chapter covers a specific topic and groups related tips and examples together.

$ Check price
14.9914.99Amazon 4.5 logo(27+ reviews)

More Linux & UNIX resources

Become a Bioinformatics Whiz!

Introduction to Bioinformatics Vol. 1

Become a Bioinformatics Whiz! Try Bioinformatics

If you're looking for a fun and easy entry point into bioinformatics algorithms, this book it just for you! Filled with graphics, and written in a light-hearted and humorous story-telling persona, Bioinformatics Algorithms guides you through the intricacies of the problems faced in biology, and the clever solutions used to solve them.

$ Check price
49.9949.99Amazon 4.5 logo(4+ reviews)

More Bioinformatics resources

Ad