Dr. Mark Gardener

Home
About
 

Index of MonogRaphs

R: MonogRaphs

A series of essays on random topics using R: The Statistical Programming Language

R is a powerful and flexible beast. Getting started using R is not too difficult and you can learn to start using R in an afternoon. However, mastering R takes rather longer! These monographs are my way of exploring various topics in a completely unstructured manner.

Tips & Tricks for R | An Introduction to R| Writer's Bloc | Courses


The Amazon tech.book store

My Amazon Profile

Learning to work with R

A question I often see in online help forums is along these lines, “I want to become an expert in R, please help”. Such messages are usually followed by replies containing plenty of links to online materials or helpful books. I have posted such replies myself. Whilst this kind of reply is undoubtedly useful it doesn’t really address the issue of how someone sets about learning to work with R.

This made me think about how I set about learning to work with R. I wondered if I could set out the key elements of the learning experience – this essay is my attempt.

Key learning elements | Look around | Be active | Solve your own problems | Keep a diary | Be persistent

This blog first appeared on the Amazon tech.book store in early April 2013.


Top

Key learning elements

The best learning experiences are practical and interactive. You learn fastest when you do something for yourself. You learn slowest when someone tells you what to do. Somewhere in-between is when someone shows you what to do.
You can split the processes involved into several inter-related parts:

  • Look around – try different resources
  • Be active – get your fingers on the keyboard
  • Solve your own problems – using your own data helps your understanding
  • Keep a diary – write down what you learn
  • Be persistent – practice makes perfect
Top

Look around

There are many resources available to help you learn R; I have written several myself (see my website). A good start is the R website at www.R-project.org where you can access many excellent documents. Try downloading some of the contributed documents, you will find that some are more helpful to you than others. Different authors have different approaches so look around and see what suits you.

There are many online forums and articles regarding R; there are Google groups, LinkedIn groups and many others besides. Have a search and see what is going on in these. Two general sites are R-bloggers and stackoverflow.

There are also many books, including my own modest contributions (see my Amazon profile). You can easily see what is available with a quick search in Amazon. Many of the books are available in electronic format, which might suit you better than a paper book. Many Amazon books have the “search inside” feature, which can help you see something of the contents.
Top

Be active

You learn best when you are doing something active for yourself. This can be as simple as copying the examples in an R textbook. As you read you should pause and copy the examples by typing for yourself. This helps you to consolidate your learning and makes it “stick”. If there are example exercises then try them out; similarly if there are summary questions then have a go and test yourself.


Top

Solve your own problems

This comes vaguely into the previous category in that it is an active process. The point is to use your own data or at least data from your own field of study/work. Solving problems from any field is useful but if you can apply what you’ve learnt to your own area of expertise you will learn quicker.


Top

Keep a diary

A really important element is being able to move forwards. If you keep forgetting details you will have to continually refer back to the book or resource that you’ve been using. Keeping your own “learning diary” can help enormously. I suggest a simple text document rather than a full-blown word processor. This is because R does not recognize “smart” quotes, so if you need to copy/paste you may run into problems.

As you learn new things you should try to write them into your learning diary right away. My own learning diary is still in use! You will soon find the best way to organize your learning diary – perhaps you might think of it as your own help file. I tend to have simple headings that categorize the things I want to recall, such as graphics, entering data and manipulating data. I might add the name of a command that I have just learnt and then include a few brief notes. Having an example that you can copy and paste into R is helpful.

At the beginning you’ll undoubtedly refer to your learning diary often. As you learn more you will find that you refer to it less often. I find that I add new stuff, to which I refer, whilst the older material is read less often.
Your learning diary could be in the form of an R script. This is just a plain text document saved with the .R extension to the filename. If you use Windows you can use the File menu to open a new or existing script (in Mac use the File menu to open or create a new document).

File Menu in Script editor
Figure 1. The File menu opens new or existing scripts (Windows version).

A script window is useful to keep snippets of code, examples and your learning diary. You can transfer command lines into R from the script window using Ctrl+R (on Mac use Cmd+Enter) and transfer material into the script from the R console using copy/paste.

Script window edit menu
Figure 2. The script window has an Edit menu allowing you to send lines to the R console.

You can easily arrange it so that you can see the R console and the script window side by side, allowing you to easily keep track of what you are doing.

Script and console together
Figure 3. Keeping the R console and script window side by side.


Top

Be persistent

There are two sayings that spring to mind: “Rome wasn’t built in a day” and “Use it or lose it”. You cannot expect to become perfect overnight and you cannot expect to remember how to carry out any particular analysis a year down the line without having practiced in the intervening period.

The point is that you need to keep using R to be really proficient with it. I used to use R for various statistical analyses and not for much else. These days I use it for trivial calculations (it is after all, a glorified calculator) and even to choose my lottery numbers!


My Amazon Profile

Top

Author Bio

Mark is an ecologist, lecturer and writer working in the UK and with a passion for learning new things. He is currently self-employed and runs courses in ecology, data analysis and R for a variety of organizations.


See my Publications about statistics and data analysis.

Writer's Bloc – my latest writing project includes R scripts

Courses in data analysis, data management and statistics.

Follow me...
Facebook Twitter Google+ Linkedin Amazon
Top Home
Data Analysis
MonogRaphs Index Contact