Beginner's guide to R: Introduction

Interest in the R statistics language is soaring, especially for data analysis. Get to know this hot programming option in our beginner's guide

Page 2 of 3

Your first step

To begin using R, head to to download and install R for your desktop or laptop. It runs on Windows, OS X and "a wide variety of Unix platforms," but not yet on Android or iOS.

Installing R is actually all you need to get started. However, I'd suggest also installing the free R integrated development environment (IDE) RStudio. It's got useful features you'd expect from a coding platform, such as syntax highlighting and tab for suggested code auto-completion. I also like its four-pane workspace, which better manages multiple R windows for typing commands, storing scripts, viewing command histories, viewing visualizations and more.

Although you don't need the free RStudio IDE to get started, it makes working with R much easier.

The top-left window is where you'll probably do most of your work. That's the R code editor allowing you to create a file with multiple lines of R code -- or open an existing file -- and then run the entire file or portions of it.

Bottom left is the interactive console where you can type in R statements one line at a time. Any lines of code that are run from the editor window also appear in the console.

The top right window shows your workspace, which includes a list of objects currently in memory. There's also a history tab with a list of your prior commands; what's handy there is that you can select one, some or all of those lines of code and one-click to send them either to the console or to whatever file is active in your code editor.

The window at bottom right shows a plot if you've created a data visualization with your R code. There's a history of previous plots and an option to export a plot to an image file or PDF. This window also shows external packages (R extensions) that are available on your system, files in your working directory and help files when called from the console.

Learning the shortcuts

Wickham, the RStudio chief scientist, says these are the three most important keyboard shortcuts in RStudio:

  • Tab is a generic auto-complete function. If you start typing in the console or editor and hit the Tab key, RStudio will suggest functions or file names; simply select the one you want and hit either Tab or enter to accept it.
  • Ctrl-up arrow (Cmd-up arrow on a Mac) is a similar auto-complete tool. Start typing and hit that key combination, and it shows you a list of every command you've typed starting with those keys. Select the one you want and hit Return. This works only in the interactive console, not in the code editor window.
  • Ctrl-Enter (Cmd-Enter on a Mac) takes the current line of code in the editor, sends it to the console and executes it. If you select multiple lines of code in the editor and then hit Ctrl/Cmd-Enter, all of them will run.

For more about RStudio features, including a full list of keyboard shortcuts, head to the online documentation.

| 1 2 3 Page 2
From CIO: 8 Free Online Courses to Grow Your Tech Skills
Notice to our Readers
We're now using social media to take your comments and feedback. Learn more about this here.