Introduction to R and Rstudio

Session - R and R studio

Zoë Turner

R vs. RStudio

R is both the name of a programming language and a program

A photo of a racing type car with the safety bars on show as it has no roof

RStudio program

RStudio is a software application with tools to

improve your programming experience

A photo of a modern car dashboard

RStudio features

  • RStudio open an R session - no longer have to think of them separately
  • All clickable areas have underlying code to automate in scripts
  • Works with other languages - not just R
  • Very easy to set up
  • New features are always added…

Open RStudio

Let’s open an R session

The Console is the R session.

You can code directly in the console…

pi*2 
[1] 6.283185
37/12 
[1] 3.083333

Screenshot of the RStudio console.

Introducing the Editor

If you don’t see the Editor pane, click top right button

And choose R Script from the drop down.

Keyboard shortcuts:
Ctrl + Shift + N
The cloud Ctrl + Shift + Alt + N

Screenshot of the menu from the icon of a white page with a green circle and a white cross

Editor features

  • The Editor is a text editor
  • Text is coloured
    (the console is one colour)
  • Autocomplete

Keyboard shortcuts:
Ctrl + Z undoes but
Ctrl + Shift + Z to redo
Ctrl + Enter runs the code

Screenshot of RStudio with 4 panels, the editor on the upper left and console in bottom left have the words to highlight their positions.

Commenting

Comment code with a hash #

# this was a bad idea

Comment frequently, at least in the beginning

Keyboard shortcut:
Ctrl+Shift+C for commenting and uncommenting

Tools > Options > workspace

Reasons why this is default

Screenshot of the Tools/Global Options wizard

Tools > Options > colours

Accessibility and comfort for all

Screenshot of the Appearance tab from Tools/Global Options wizard

Packages

R packages are like apps for your phone:

Extend the capabilities of the basic or “base R”
with extra functions, datasets, code examples & documentation.

Simple flowchart of packages installation to loading and how that matches the download app to open app on a mobile phone

End Session