Using the Built-In Help Function in R Programming

Instructor: Gary Dohmeier II

Gary is an independent consultant, working in IT for over 25 years. He has a BS in Computer Science from the Univ. of Baltimore.

In this lesson we will learn about the help system built into the R language. We will learn how to access the R help functionality and also provide some examples of using the R help system.

Getting Help with R

When using a new language or tool, a user will frequently need help... with basic syntax, control structures, and how to use advanced functions. The help documentation is typically provided in separate PDF documentation or online web pages, and the program code is composed in a text editor and then compiled and run. But interpreted languages like R actually have a help subsystem built right in. The R language has a comprehensive, embedded help system which can be easily accessed from the command line.

The R language help system is accessed from the command line, and has many different options and access methods which we will discuss in the next section.

R Has Built-in Help

The help system for R is built into the language as a subsystem. There are various ways to access the R help subsystem. Accessing help from the command line is similar to the Linux 'man pages'. But there are also other ways to get help, such as a web browser and website searches.

Some of the ways you can use help are:

  • The help() function or ? operator - for help on commands and packages
  • The example() function - to see examples of code
  • The browseVignettes(), vignette() and demo() functions - for actual implementations that solve or demonstrate things
  • The apropos(), and RSiteSearch() function - for when you don't know the name of the R function exactly
  • The help.start() function - to start the hyperlinked online version

We will discuss each of these in the following section.

How to Use the R Help System

In this section we will discover the many ways that the R help facility can be accessed and used. We will be providing several examples to show how you can query for help and the type of output provided. Type each of these into your R command line and observe the results.

The Help() Function or ? Operator

If you know the name of the command, you can use either help(command) or ?command where ''command'' is the name of the R command or package. The ? is operator is like help() using a slightly simpler syntax.


  • help(): this provides help on using the help() function itself
  • help(mean): this returns help about the arithmetic mean() function.
  • help(package=base): this returns information about the base package.
  • ?mean: this is the same as help(mean)
  • ?'while' or ?'*': these returns information on control structures or unary operators (enclose these in single quotes)

The Example() Function

R provides the example() function too. If you want to see an example of a command in use, this will help you. Many help systems describe what commands can or can't do, but may still leave you wondering how to use them. If this happens to you, check out this function.


  • example(mean): this provides example code so you can see how to use the arithmetic mean function
  • example('for'): this provides examples so you can see how to use ''for'' loops

The BrowseVignettes(), Vignette() and Demo() Functions

These functions provide help in the form of actual implementations that solve or demonstrate how to accomplish something in R. An example would be the psych package for psychometrics which you can find listed under browseVignettes().

To unlock this lesson you must be a Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use

Become a member and start learning now.
Become a Member  Back
What teachers are saying about
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 160 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create An Account