Dr. Mark Gardener

Home > Publications > Essential R Support

The Essential R Reference

by: Mark Gardener

Support and Outline

Welcome to the support page for my book, The Essential R Reference. Here you will find a Table of Contents and brief outline to help you see what's included in each section of the book. The book includes many examples and there is a file that you can download, which contains data used in these examples. This one file contains the example data sets you need for the whole book; it contains very few because I have tried to make all data fairly simple and short so that you can type it directly.

How This Book is Structured | Table of Contents | Example Data File


The Essential R Reference is available now! See it at Wiley or on Amazon.co.uk

Get example data used in the book

More about R

The R website

My Amazon author profile

Back to top

An essential companion in your day-to-day conversations with R

R is a language with its own vocabulary and grammar. To make R work for you, you communicate with the computer using the language of R and tell it what to do. You accomplish this by typing commands directly into the program. This means that you need to know some of the words of the language and how to put them together to make a “sentence” that R understands. This book aims to help with this task by providing a “dictionary” of words that R understands.

The help system built into R is extensive, but it is arranged by command name; this makes it hard to use unless you know some command names to start with. That’s where this book comes in handy; the command names (the vocabulary of R) are arranged by topic, so you can look up the kind of task that you require and find the correct R command for your needs.

Each command listed in this book has an explanation of what the command does and how to use it—the “grammar,” if you will. Related commands are also listed, as in a thesaurus, so if the word you are looking at is not quite what you need, you are likely to see the correct one nearby. There are also examples of each command “in action” so you can gain a better understanding of how the command works.

I like to think of this book as a cross between a dictionary, a thesaurus, and a glossary, with a fair sprinkling of practical examples. Even though some may consider me an “R expert” at this point, I am still learning and still forgetting! I often have to refer to notes to remind me how to carry out a task in R. That is why I wrote this book—to help novice users learn more easily and to provide more experienced users with a reference work they can delve into time and time again. I also learned a great deal more about R by writing it, and I hope that you will find it an essential companion in your day-to-day conversations with R.

This book is organized in a topic-led, logical manner so that you can look for the kind of task that you want to carry out in R and find the command you need to carry out that task as easily as possible, even if you do not know the name of the command. The book is split into four grand themes:

  • Theme 1: "Data"
  • Theme 2: "Math and Statistics"
  • Theme 3: "Graphics"
  • Theme 4: "Utilities"

These are hopefully self-explanatory, with the exception perhaps of “Utilities”; this covers the commands that did not fit easily into one of the other themes, particularly those relating to the programming side of R.

The outline covers each chapter/theme of the book.

Download the Essential.RData file for example data used in the book

Back to top

How This Book Is Structured

Each of the topics is also split into subtopics to help you navigate your way to the command(s) you need. Each command has an entry that is split into the following sections:

  • Command Name—Name of the command and a brief description of what it does.
  • Common Usage—Illustrates how the command looks with commonly used options. Use this section as a memory-jogger; if you need fine details you can look in the “Command Parameters” section.
  • Related Commands—A list of related commands along with the page numbers or a link to their entries so you can easily cross-reference.
  • Command Parameters—Details of commonly used parameters for the command along with an explanation of what they do.
  • Examples—Examples of the command in action. The section is set out in code style as if you had typed the commands from the keyboard yourself. You also see the resulting output that R produces (including graphical output).

Some commands are relevant to more than one theme or section; those commands either have a cross-reference and/or have an entry in each applicable place.

Download the Essential.RData file for example data used in the book

Back to top

Theme 1: Data

This theme is concerned with aspects of dealing with data. In particular:

  • Data types–Different kinds of data and converting one kind of data into another kind.
  • Creating data–Commands for making data items from the keyboard.
  • Importing data–Getting data from sources on disk.
  • Saving data–How to save your work.
  • Viewing data–Seeing what data you have in R.
  • Summarizing data–Ways of summarizing data objects. Some of these commands will also appear in Theme 2: “Math and Statistics.”
  • Distribution of data–Looking at different data distributions and the commands associated with them, including random numbers.

Download the Essential.RData file for example data used in the book

Back to top

Theme 2: Math and Statistics

This theme covers the commands that deal with math and statistical routines:

  • Mathematical operations–Various math, including complex numbers, matrix math and trigonometry.
  • Summary statistics–Summarizing data, some of these commands are also in Theme 1: “Data.”
  • Differences tests–Statistical tests for differences in samples.
  • Correlations and Associations–Including covariance and goodness of fit tests.
  • Analysis of variance and linear modeling–Many of the commands associated with ANOVA and linear modeling can be pressed into service for other analyses.
  • Miscellaneous analyses–Non-linear modeling, cluster analysis, time-series and ordination.

Download the Essential.RData file for example data used in the book

Back to top

Theme 3: Graphics

This theme covers the graphical aspects of the R language:

  • Making graphs–How to create a wide variety of basic graphs.
  • Adding to graphs–How to add various components to graphs, such as titles, additional points and shapes.
  • Graphical parameters–How to embellish and alter the appearance of graphs. Including how to create multiple graphs in one window.

Download the Essential.RData file for example data used in the book

Back to top

Theme 4: Utilities

This theme covers topics that do not easily fit into the other themes:

  • Installing–Notes on installing R and additional packages of R commands.
  • Using R–Including accessing the help system, history of previously typed commands and managing packages.
  • Programming–Commands that are used mostly in the production of custom functions and scripts. These can be thought of as the “tools” of the programming language.

Download the Essential.RData file for example data used in the book

Back to top

The Essential R Reference: Example data file

The book includes many examples and data used are included in the Essential.RData file. This one file contains the example data sets you need for the whole book; it contains very few because I have tried to make all data fairly simple and short so that you can type them directly.

Get the example data

You can download that file by clicking on the link. This one file contains all the example datasets you need for the whole book. Most examples are simple enough to type from the keyboard but some needed to be a bit longer and more complex. These data are included in the Essential.RData file for you to load into R, ready to use.

Install the example data

Once you have the file on your computer you can load it into R by one of several methods:

  • For Windows or Mac you can drag the Essential.RData file icon onto the R program icon; this will open R if it is not already running and load the data. If R is already open, the data will be appended to anything you already have in R otherwise only the data in the file will be loaded.

If you have Windows or Macintosh you can load the file using menu commands or use a command typed into R:

  • For Windows use File, Load Workspace, or type the following command in R:


  • For Mac use Workspace, Load Workspace File, or type the following command in R (same as in Windows):


  • If you have Linux then you can use the load() command but must specify the filename (in quotes) exactly, for example:


The Essential.RData file must be in your default working directory and if it is not you must specify the location as part of the filename. Alternatively you can find the working directory in R by using the getwd() command:


Then drag the Essential.RData file into that directory and use the load() command:


Using the example data

R uses named objects so everything gets a name. You can see what is included in the Essential.RData file by using the ls() command:


This will show you everything currently in the memory of R. Remember that names are case sensitive so that Qty is not the same as qty. Most of the examples used in the book use data that is simple enough to type directly into R or is available as part of the R datasets package that is available when you install R on your computer. The Essential.RData file contains datasets that I thought were too long and complicated to type directly into R.

My other publications


Contact GardenersOwn Homepage