Working with R

  • The R Console “interprets” whatever you type
    • Calculator
    • Creating variables
    • Applying functions
  • “Analysis” Script + Interactive Exploration
    • Static copy of what you did (reproducibility)
    • Try things out interactively, then add to your script

R essentially is a command line with a set of functions loaded

R Uses Functions, in Packages

  • R revolves around functions
    • Commands that take input, performs computations, and returns results
    • When you download R, it has a “base” set of functions/packages (base R)
  • Functions are enclosed in packages
    • These written by R users/developers (like us) - some are bad
    • Think of them as “R Extensions”

Using Packages

  • You need to know base R - answers on Google commonly use it
  • We will show you some newer and more intuitive ways to do things, not in base R
  • RStudio (the company) makes a lot of great packages
  • Hadley Wickham writes a lot of them (Employee and Developer at RStudio)

RStudio (the software)

RStudio is an Integrated Development Environment (IDE) for R

RStudio

Easier working with R

  • Syntax highlighting, code completion, and smart indentation
  • Easily manage multiple working directories and projects

More information

  • Workspace browser and data viewer
  • Plot history, zooming, and flexible image and PDF export
  • Integrated R help and documentation
  • Searchable command history

RStudio

RStudio

Let’s start by making an RStudio “Project”.

  1. Helps you organize your work.
  2. Helps with working directories (discussed later).
  3. Allows you to easily know which project you’re on.

Go to File → New Project → New Directory → New Project

Call your Project “Intro_to_R”

RStudio/R Console