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 Programming

Learn to be a Pythonista! Try Python

This book is designed to be used as the primary textbook in a college-level first course in computing. It takes a fairly traditional approach, emphasizing problem solving, design, and programming as the core skills of computer science. However, these ideas are illustrated using a non-traditional language, namely Python.

$ Check price
45.9945.99Amazon 4.5 logo(211+ reviews)

More Python resources

Take your Linux skills to the next level!

Linux for Beginners

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

Linux for Beginners doesn't make any assumptions about your background or knowledge of Linux. You need no prior knowledge to benefit from this book. You will be guided step by step using a logical and systematic approach. As new concepts, commands, or jargon are encountered they are explained in plain language, making it easy for anyone to understand.

$ Check price
24.9924.99Amazon 4.5 logo(101+ reviews)

More Linux & UNIX resources

Ad