STAT 451, Day 2

Let's do this!

This Course

In this course we are going to examine Data Visualization examples, methods, and software.

You will have the opportunity to work with data to create visualizations.

Let's look at R Studio!

Example 1

  • In R, type
    • demo(graphics)
  • Let's look at the dataset cars. The data give the speed of cars and the distances taken to stop. Note that the data were recorded in the 1920s.
  • In R, type
    • cars
      • Why are we not content with showing people this dataset as given above?
    • summary(cars)
      • How is this better? Can we do even better?
    • plot(cars)
      • What have we gained?

Example 2

library(quantmod) # must be installed if you don't already have it

require(quantmod)
getSymbols('GOOGL', from='2014-06-01', to='2018-04-01')
[1] "GOOGL"

Example 2 cont.

plot(GOOGL[,4])

plot of chunk stockscont

In this code, 'GOOGL' is the stock market symbol for Google (Alphabet).

R Help

  • R Help (introduces how to get help)
  • R Site Search (R site search for functions)
  • Within R,
    • ?foo (if you know the function is called foo)
    • help.search('foo.things') if you don't know the function name
    • ??foo.things
    • RSiteSearch('foo.things') brings you to R site search
  • Good ol' Google

R Markdown

Markdown is a great way to present your information while seemlessly inserting your R code and results.

Let's make an R Markdown together!

Example

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