Previous chapter
Installation and First StepsOverview
Next chapter

Prequisites

For this course you only need a laptop and a fairly modern web browser.

However, if working locally you need to install the following components:

Basic Ways to Interact with R

NameDescriptionUsed For
RtermR through Command LineBatch Processing/Automation
RGuiR through minimal GUIQuick Tasks
RStudioFully-fledged IDEProjects

Below you see an exercise example window. Just use R instead of your pocket calculator:

RStudio

  • Application looking similar to classical spread sheet software
  • Full-fledged coding environment to create R scripts (among many other things)
  • Runs on all major operating systems including Windows, MacOS and Linux.

{width=“100%”}

You can open RStudio directly in the browser by clicking the Start/Open Workspace button.

RStudio’s Productivity Tools

  • Editor: Syntax highlighting, code completion, and smart indentation
  • Console: Execute R code directly from the source editor
  • Output: Plot history, zooming, and flexible image and PDF export

Contents of the R software package{width=“100%”}

Additional Features

Additionaly the following features are available:

  • Easily manage multiple working directories using projects
  • Quickly navigate code using type-ahead search and go to definition
  • Workspace browser and data viewer
  • Integrated R help and documentation
  • Markdown, LaTeX, and Sweave authoring including one-click PDF preview
  • Interactive Debugging
  • Integrated with Git and Subversion for version control

First Steps

Let’s have a look what the RStudio IDE can do for us. We will briefly present the major tasks of RStudio:

  • How to create, edit and save your source code
  • How to run your code in the console
  • How to plot graphs and images
  • How to make use of the searchible history
  • How to manage the Workspace
  • How to make your work more productive with projects

We can now start the RStudio workspace to perform the steps above.

Advanced

  • How to integrate your work to Git and Subversion
  • How to author LaTeX and Sweave documents to get PDF docs

RStudio Documentation

  • Screenshots provide a good starting point.
  • Documentation provides a huge bulk of detailed information.
  • Cheat Sheet at Help -> Cheatsheets -> RStudio IDE Cheat Sheet
  • O’Reilly book written by John Verzani: Getting Started with RStudio

{width=“100%”}

Packages

A package can be distributed as

  • Source package
  • Binary representation of the corresponding source package.

The main distribution channels (aka R repositories) include:

R help

This is all documented in TFM. Those who WTFM don’t want to have to WTFM again on the mailing list. RTFM. – Barry Rowlingson R-help (October 2003)

R Environment

What are HOME, working and other directories?

  • Working directory: where R was started (or set via getwd(), setwd()).
  • HOME directory: on Windows 7 usually "C:/Users/username/Documents".
  • R_HOME: the installation directory.
  • Package library: where the packages are installed.

Working Directory

Check the current working directory using the getwd() command.

Working Directory

What is the difference between the working directory, the home directory and R_HOME? Check the files in those directories using the dir() function.

Quiz (1)

Check which statements regarding the working directory and file system are correct:

Quiz (2)