September 25, 2017

General

Annoucements

  • Don't forget: Assignment 1, Part B due on Friday, September 29

dplyr package (continued)

Get copy of dplyr demo repository

  • Pull up demo repository we used during class last time.

  • If you need to re-clone, find the repo on the website, fall17.cds101.com

    • Click Materials → Materials for Class 8
  • Load in RStudio, and follow along in demos

mutate()

Using mutate(): common creation functions (commands)

  • Many different operators and functions can be used with mutate()

  • Arithmetic operators: +, -, *, /, ^

  • Modular arithmetic

    • %/%: integer division

    • %%: remainder

  • Logs: log()

  • Logical comparisons: <, <=, >, >=, !=

mutate() demo

Follow along in RStudio

group_by() and summarize()

Common functions (commands) for summarize()

  • n(): Counts number of rows in a group

  • sum(): For numerical variables, sums rows within a group

  • statistical: mean(), median(), sd(), min(), max()

  • Counts and proportions of logical values: sum(x > 10), mean(y == 0)

group_by() and summarize() demo

Follow along in RStudio