Prepare your project

Duration: ~10 Minutes

Clock made of Legos

Learning Objectives

  1. Create your project
  2. Create your script
  3. Load relevant package(s)

New RStudio Project

File -> New Project -> New Directory

Create an empty project

Name your project

RStudio: New Project

Our New Project


R version 3.3.3 (2017-03-06) -- "Another Canoe"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> getwd()
[1] "/home/abby/foo"
    

Locate your new folder.

foo.Rproj is an RStudio file.

Your Turn! Create a script.


# Author: 'your name'
# Date: 'today'
# Purpose: example template

## Load some data
data(cars)

## Look at it
str(cars)

## Play with it 
colMeans(cars)
    

Save as my_cars.R. What happens?

Folder Structure

Root Project Folder (foo):

  • data/
    • README.md
    • something_awesome.R
    • something_awesome.Rda
  • R/
    • README.md
    • awesome_function.R
  • README.md
  • explore.R
  • some_awesome_analysis.R

Documentation

Document everything.

  • README.md is a naming convention.
  • *.md are text files written in Markdown.

We will cover Markdown in a future workshop.
For now, use plain text.

Packages

... simplify your life


Install and load with


# plural; package name in quotes
install.packages("tidyverse")
# singular; quotes not needed
library(tidyverse)
    

And Now You Know!

Q & A