You are on page 1of 2

R Help Sheet 3: Getting Help


A guide to finding the information you need to help you use R and debug problems.

1. Checking your code

The vast majority of error messages from R arise because of simple grammatical mistakes. Missing
commas, capital letters, quotation marks or misspellings will mean that R can’t find the object,
function or argument it needs, so check each line of code carefully before worrying that something is
going wrong. Although this can be frustrating at first, with practice you’ll get much quicker at
spotting your mistakes and save yourself a lot of time.

2. Using the help function

Help on any function (e.g. t.test) can be found by typing either ?t.test or help(t.test). This will bring
up a help page on the function from within R.

The R help pages contain a lot of R jargon and can be quite bewildering at first. However, it isn’t
necessary to understand everything on the help page to find the parts you need, and there’s a lot of
useful information on there. Below is an example help page for the t.test function with a guide to
the different sections and what they mean; type help(t.test) and refer to the help page as you read

Description gives a simple description of what the function does; usually pretty self-explanatory.

The Usage section tells you what arguments the function accepts and the Arguments section tells
you what those arguments actually mean. There’s no need to understand everything in these
sections as they will often contain a lot of extra info you don’t need, but you can often pick up some
useful things.

For example, we can see that t.test can accept one or two numeric vectors, x and y, for performing
one-sample or two-sample t-tests. We can also see that we can do a two-sample or paired t-test
using paired=TRUE or paired=FALSE. Note that the default in this case, given in the Usage section, is
FALSE. We can also specify whether we want to do a one-tailed or two-tailed test using alternative =
“two.sided”, “greater”, or “less” than our null hypothesis value (given by mu, and set to mu=0, i.e. no
difference, by default). If you’re struggling to remember the differences between paired and
unpaired or one-tailed and two-tailed tests, there’s more info in Lectures 5-8 and help sheet 5 – but
the key thing here is that the Usage and Arguments sections tell you what goes inside the brackets of
the function you want to use.

The Value section tells you about the outputs for a function, such as test statistics or p-values from a
statistical test. These can often be chained onto your test using the dollar sign $ and used to extract
the particular parts you need. For example, if we make assign our t.test to a new object (here called
mytest), we can extract the p-value using mytest$p.value:

BIO2426 Analysis of Biological Data Page 1 of 2

At the bottom of the help page is an Examples section which gives some example code you can run.
However, this is often quite complicated and it’s usually easier just to find examples from a lecture
or from a book (see below).

3. Useful books

Probably the most useful reference book for R is “The R Book” by Crawley. You can look up functions
in the index to find examples where they’re used, or look up the topic you’re working on and see if
you can find functions that might come in handy. However, although an excellent reference manual
for using R, The R Book isn’t the most user-friendly in terms of actually learning how the statistics
work and what they mean. This means it’s often worth reading up on the theory elsewhere, and only
turning to The R Book when you know the test you want to use and just need to know how to do it in
R. In fact, this is a good way to approach statistics generally: sit down and have a careful think about
what it is you want to know about your data before you worry about what test you need to use.

4. Useful websites

One of the most useful websites is the Quick R website ( This has
concise guides to the most useful functions in R along with some useful examples. There’s also a very
good section on making graphs in R (see also Help Sheet __). A variety of more specific problems are
tackled on other web-pages, so a Google search is often worth a try.

The following websites also provide tutorials in R, at varying levels of difficulty:

5. The R forums

The R mailing lists archive ( isn’t always the most accessible
source of information, but there’s tons of useful stuff on there. People post R-related questions and
get them answered by top statisticians and other R users that have experienced similar problems.
Often, by searching for a few key words, or the error message you’ve got, can find an exact answer
to your problem. This can come in very handy later on when you’re doing your third year projects
and you come across questions that aren’t covered in the lectures or help sheets.

BIO2426 Analysis of Biological Data Page 2 of 2