Keywords

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

FormalPara Prerequisites and goals of this chapter
  • Chap. 3.

  • This chapter presents the various ways to get help on the R software.

1 Integrated Help

1.1 The Command help()

R includes an online help. It is very complete and very well structured for all functions and for the various symbols in the language. There are several ways to access the help files; the main method is help(). It is used in command line mode.

For example, type:

 help(help)

There is an alias for the command help(): the question mark ?.

 ?sum

 ?sd

 ?"+"

 ?"[["

Warning

Sometimes, this alias will not work. In those cases, you will need to use the function help() with quotation marks.

 ?function        # Does not work.

 help(function)   # Returns an error.

 help("function") # Correct call.

Let us look at the help of the function mean().

Here are the sections of this help file:

    1. The header of the file, with:

    • The name of the function: mean

    • The name of the package in which the function is included: base

    • The origin of the help file: R Documentation

    1. An explicit title for the function: Arithmetic Mean

    2. A brief description of what the function does: Description

    3. How to use the function; in particular, the compulsory and optional arguments: Usage

    4. A description of the function’s arguments: Arguments

    5. Explanations on the output of the function: Value

    6. References (statistical articles or books) related to the function’s application domain: References

    7. The See Also section, which lists similar or related functions

    8. Examples of use: Examples

Warning

Most help files follow this format. Make sure you understand and remember the structure of help files. You should also take the habit of checking the online help whenever you meet an unknown function, so as to understand its arguments and use.

Tip

Note that help files do not include graphs, for example, those that could be produced with the code in the section Examples \(\bigcirc \!\!\!\!9\). This would be interesting, especially for all the graphical functions. One way to get them is the function example(). You can also browse the website R Graphical Manual: http://bm2.genes.nig.ac.jp/RGM2/index.php which includes all R help files in HTML. In those files, when there are graphs, they are directly included in the section Examples.

1.2 Some Complementary Commands

In addition to the main command, help(), a few other complementary functions can be useful when looking for help on a given command. They are listed here:

  • help.start(): this function opens a web browser with links to handbooks in HTML, help on functions included in all R packages (also HTML), a FAQ (Frequently Asked Questions), and a search engine of the help files. There are also other more technical documents.

Linux

Under Linux, once you have entered the command help.start(), using the command help() will always result in the help being displayed in the web browser, rather than in the command line. To cancel this behaviour, use the instruction options(htmlhelp = FALSE). To change browser (e.g., firefox), use the instruction options(browser="firefox").

  • help.search() or ??(): this function is useful when you do not know the name of a command. It returns a list of functions (and the package in which they are included) related to your request. Try: help.search("mean").

  • apropos(): this instruction returns the names of functions which are a (potentially partial) match to the calling argument. For instance, apropos("mean") returns the names of functions containing the word mean.

Advanced users

Note also that the function methods() returns all the methods (functions) associated with an object. For instance, try methods(summary).

  • library(help=package): this command lists all functions included in a package. It gives the same results as the command help(package="package"). We advise you to try the following instructions to list the main functions in R:

    library(help=base)

    library(help=utils)

    library(help=datasets)

    library(help=stats)

    library(help=graphics)

    library(help=grDevices)

Tip

The function library(lib.loc =.Library) returns the list of all packages (or libraries) installed on the system.

Conversely, the instruction find(" function ") indicates in which package a function is included.

>  find("t.test")

 [1] "package:stats"

  • vignette(): vignettes are small PDF files which explain some notions in further detail. Type vignette() to get a list of vignettes, and for example vignette("xtableGallery") to open the PDF vignette of the package xtable.

Mac

All vignettes can also be read in a special vignette browser, from the menu “Help/Vignettes”. In this browser, you can open PDF files as well as R source code (as .R files) and consult directly the code of examples included in the vignette.

These three other functions might also be useful:

  • data(): this command lists all datasets included in R.

  • example(): this instruction lists examples of use of a function. For example, example(mean) executes the instructions included in the section Examples of the help file help(mean).

  • demo(): this instruction is similar to example(), but is only available for a small number of functions. When it is available, it shows the range of possible uses of a function. For example, try demo(graphics).

2 † Help on the Web

The official R website (http://www.r-project.org) includes a huge amount of information about this software. You should spend some time exploring it. The following sections list other sources of information.

2.1 Search Engines

There are two main search engines for R:

Tip

The command RSiteSearch() can be used to send a request on this website directly from R. The information is then displayed in your browser.

There is also a very interesting collaboratively edited question and answer site for programmers available at URL http://stackoverflow.com/questions/tagged/r.

2.2 Message Boards

There are many message boards about R, where you can ask your questions. One message board with a lot of traffic is http://r.789695.n4.nabble.com.

2.3 Mailing Lists

A mailing list is a specific kind of e-mail, which sends messages to a large number of subscribers.

There are several mailing lists about R. The main ones are:

The website http://r-project.markmail.org can be used to search the archives of these lists.

You need to follow a few rules to post a message on these lists, as described here: http://www.r-project.org/posting-guide.html.

Mac

A list dedicated to Mac users: https://stat.ethz.ch/mailman/listinfo/r-sig-mac.

2.4 Internet Relay Chat (IRC)

IRC (Internet relay chat) is a real-time messaging service. You can use it to chat with other Internet users on predefined themes. The IRC channel on the R software is called (#R) on the freenode server.

To access it, you can either use client-side software such as xchat (www.xchat.org) or use your browser through websites such as https://webchat.freenode.net.

To connect to this channel using xchat, type in these instructions:

/server irc.freenode.net

/join #R

2.5 Wiki

A wiki is a website where pages can be freely edited by visitors. Wikis are used to aid collaborative writing with minimal constraints.

There is a wiki about R here: http://rwiki.sciviews.org.

3 † Literature About R

3.1 Online

Literature about R is available online in many forms:

3.2 Printed Material

Many books have been published about R recently. We find the following to be the most interesting:

  • Data Analysis and Graphics Using R:An Example-Based Approach [26]

  • The R Book [12]

  • Statistics and Data with R [10]

  • Software for Data Analysis: Programming with R [8]

  • Lattice: Multivariate Data Visualization with R [36]

  • R for SAS and SPSS Users [32]

  • Introductory Statistics with R:An Applied Approach Through Examples [13]

  • A First Course in Statistical Programming with R [6]

  • A Handbook of Statistical Analyses Using R [15]

  • A Beginner’s Guide to R [42]

  • R Cookbook [39]

  • R in a Nutshell [1]

  • The Art of R Programming [28]

  • The R Inferno [7]

Memorandum

  • help(), ?(): get help on a function or a symbol

  • help.search(): list of functions relevant to your request

  • apropos(): list of function names which include the request

  • library(help=package): list of all functions in a package

  • data(): list of all datasets available in R

  • example(): execute the Examples section of the corresponding help file

  • demo(): launch a small demonstration of the possible uses of a function

  • vignette(): open a PDF file with details on a function

  • help.start(): open the HTML version of the R help files

  • RSiteSearch(): start a request on the official R website search engine

Exercises

  1. 6.1-

    Which R instruction should you type to get help on the function mean()?

  2. 6.2-

    Explain the purpose of the command apropos().

  3. 6.3-

    Explain the purpose of the command example().

  4. 6.4-

    Explain the purpose of the command RSiteSearch().

  5. 6.5-

    How is a help file structured?

  6. 6.6-

    Which command would you use to get the list of functions available in the package stats?

  7. 6.7-

    Explain how to display a dataset available in R.

Worksheet

Where to Find Information

  1. 6.1-

    Find the R function which lists all combinations of k elements out of n.

  2. 6.2-

    Use this function to list all combinations of three elements out of c(5,8,2,9).

  3. 6.3-

    Find the dataset available in R which gives the rates of violent crimes in the USA.

  4. 6.4-

    Describe the contents of this dataset.

  5. 6.5-

    Subscribe to the mailing list https://stat.ethz.ch/mailman/ listinfo/r-help.

  6. 6.6-

    Read the rules to follow before asking a question (http://www.r-project.org/posting-guide.html).

  7. 6.7-

    Find out how to unsubscribe from the mailing list.

  8. 6.8-

    Using the method of your choice, join the IRC channel R and start a polite conversation with channel members.

  9. 6.9-

    Register on the message board http://r.789695.n4.nabble.com.

  10. 6.10-

    Read the R FAQ for Microsoft Windows. Try to understand the meaning of TAB completion.

  11. 6.11-

    Use TAB completion to list all files in the current directory.