Introduction to R

What is R and Why Should You Use It?

Jason Freels

16 December 2016

WELCOME!

This Presentation Covers...

WHAT IS R?

In a Nutshell, R is...

IEEE Ranking Of Top Programming Languages

2015 Rankings

2016 Rankings

Where Did R Come From?

HOW DOES R COMPARE TO OTHER LANGUAGES

R vs. Proprietary Source Languages

Proprietary Source
  • Methodical updates (annually/bi-annually)

  • Consistent syntax/user experience across all functions

  • Single learning curve to becoming proficient

  • Strategic improvements, carefully implemented

  • Won't alienate legacy users with drastic changes

  • Newest methods may not be available for a while

  • Expensive
R (Open Source)
  • Fast updates - newest capabilities are released every day

  • Strategic improvements to R-Core

  • Package authors are independent - proceed in their own directions

  • Flexible syntax - often NOT consistent

  • Multiple learning curves for different packages

  • Legacy users often frustrated with fast-paced changes

  • Free

ADVANTAGES AND DISADVANATAGES OF USING R

Advantages

Disadvantages

IS R FAST? (YES AND NO)

Human efficiency vs. Machine efficiency

UNDERSTANDING THE R ENVIRONMENT

Basic Structure of R

Everything in R is an OBJECT...Almost

Assigning names to objects - R is CasE sENsItiVE!!

var <- 5  ### Left assignment
200 -> Var ### Right assignment
meaning.of_life = 42 ### Or equal sign
var; Var; meaning.of_life
[1] 5
[1] 200
[1] 42

HELPFUL FUNCTIONS

Functions to access R object properties

mode(object.name)  ### Returns an object's mode 
class(object.name) ### Returns an object's class
attributes(object.name) ### Returns any attributes associated with an object
str(object.name) ### Returns a complete list of properties assigned to an object
str( ) is every R users best friend

Functions to manage active objects

ls( ) ### Returns a list of active objects in the current working environment
rm( ) ### Removes an object from the current working environment
rm(list = ls()) ### Removes all objects from the current working environment (use carefully)

Functions to manage your local file structure

getwd( ) ### Returns the location of the current working directory
setwd("C:/Users/Desktop") ### Reassigns the location of the working directory
file.choose( ) ### Opens a new file explorer window to choose a file

Help Resources Within R

?cos ### Searches the local package library for "cos"
??xyz ### Searches the full R documentation for "xyz" - also help(xyz)
vignette() ### Lists "how-to" demos available for each package in the library
help.search("t.test") ### Provides a categorized search of R documentation for "t.test"

Online Resources for Help