3/24/2018

Base R

Base R refers to the collection of functions that come with a clean install of R.

Base R

Base R refers to the collection of functions that come with a clean install of R.

Examples:

  • The dollar notation: sleep$extra
  • Matrix notation: sleep[, "extra"]
  • Summarizing functions: mean(), sd()
  • Plotting functions: plot(), hist()
  • Data import functions: read.csv()

The tidyverse

The tidyverse is an opinionated collection of R packages designed for data science.

The tidyverse

The tidyverse is an opinionated collection of R packages designed for data science.

Included packages:

  • readr
  • dplyr
  • tidyr
  • ggplot2
  • …and more

https://www.tidyverse.org

The tidyverse

All packages share an underlying design philosophy, grammar, and data structures.

What makes good code?

Elegance?

What makes good code?

Good code is correct, fast, readable.

What makes good code?

Good code is correct, fast, readable.

And predictable.

Why do we care?

Understanding code is hard. Even when you yourself wrote it.

You want your code to be understood by collaborators, fellow academics, and yourself at a later time.

Coding consists mostly of looking at other people’s code.

While learning R, it’s easier if the code is understandable.

Demo

Base R vs. the tidyverse

Human factors are my main argument for why I favor the tidyverse.

Demo

Discussion

The tidyverse

Main benefits:

  • Easy to read
  • Consistent

The tidyverse

Main benefits:

  • Easy to read
  • Consistent

This makes R a LOT easier to use/learn.

Limitations

  • Sometimes performance determines everything
  • the tidyverse is under development, so things change
  • I did not discuss the data.table package

More information