Getting Help in R


Getting Help in R

One of the most important features that you will need as you start on your path to becoming and R user is getting help. No matter how skilled of a programmer you are, you always encounter new functions and need help understanding how to use them. We will take some time to explore the help features in R.

The help() Function

To get online help within an R session we use the help() function. This will allow us to see the documentation on a function that we are interested in.

Help Function Example

Lets say for example that we wish to to make a sequence. We may read from a blog post or online website that we can do this with a function called seq(). Unfortunately for us most people do not really display how to use the functions that they list. Have no fear! R will help:

help(seq)

If you type the above command into your R Studio window you

?seq

Further Help Function Use

Many times we do not know exactly which function we can use. In order to ask R for help in this case we can actually search all the packages we have for a keyword or phrase.

For example if we wanted to know about math symbols we could type the following:

help("<")
help('<')
?"<"
?'<'

Enter the above searches into RStudio to see what you get.

?"for"

The same works for keywords.

The example() Function

Many times we just need to see some examples rather than read the entire documentation of a function or command. In this situation we would use the example() function

example(seq)

Type the above command into RStudio and see what you get when you do this. You may find it useful to see the code in action before trying in yourself.

We can then see numerous examples that R has run for us. The benefit of this command comes when you are interested in seeing examples of graphics, where just seeing the command and not the final product may not be as intuitive for us

Consider below where we might be interested in some perspective plots. When you enter this into RStudio you will see some of the beautiful graphics that R can do:

example(persp)

Internet Help

Aside from these areas of help another method is to search the internet for further help. Here are some other resources:

The Comprehensive R Archive Network

UCLA Statistical Computing Help Site

Google Search Site

Github

StackExchange