R Review

Illya Mowerman, Ph.D.

University of Bridgeport

What is an object?

An object:

  • Contains data
  • May have a hierarchy
  • Has a name
  • Has a class (is of a type)

Examples of types of objects

  • Vector
  • Dataframe
  • Graph
  • Function
  • List

Packages

Packages are functions that are created be the R community and have made them available to all

Installng packages is easy:

install.packages('dplyr' , repos='http://cran.us.r-project.org')

The downloaded binary packages are in
    /var/folders/8c/w4htphd93r7cq7tcyp65xr780000gn/T//Rtmp2c6JT9/downloaded_packages

Loading Packages is even easier

To be able to use the functions of a package, you must load it first

library(dplyr)

Highly used packages for this class

  • tidyverse (tibble , tidyr, readr, & dplyr)
  • stringr
  • rmarkdown
  • lubridate

Getting data into R

There are many ways to get data into R:

  • Reading from a local file
  • Through a connection to a database (any database)
  • API
  • Web scraping

We will be reading in files

The easiest way to import data using the Import Dataset functionality within RStudio. You will find this under the Environment Tab

First Slide

For more details on authoring R presentations please visit https://support.rstudio.com/hc/en-us/articles/200486468.

  • Bullet 1
  • Bullet 2
  • Bullet 3

Slide With Code

summary(cars)
     speed           dist       
 Min.   : 4.0   Min.   :  2.00  
 1st Qu.:12.0   1st Qu.: 26.00  
 Median :15.0   Median : 36.00  
 Mean   :15.4   Mean   : 42.98  
 3rd Qu.:19.0   3rd Qu.: 56.00  
 Max.   :25.0   Max.   :120.00  

Slide With Plot

plot of chunk unnamed-chunk-4