Data Challenge Lab Home

Vector and summary functions [wrangle]

(Builds on: Manipulation basics, Missing values)

library(tidyverse)
library(nycflights13)

mutate() and summarise() operate on data frames. You use them with vector and summary functions which work with individual variables (or vectors).

Vector functions

A vector function takes one (or sometimes more) vectors as input and returns a vector of the same length as output. These are typically used with mutate() to create new variables.

I can’t list every vector function, but here’s a few that are often useful:

Summary functions

A summary function takes a vector of inputs and returns a single output. They are most commonly used with summarise().

Just using means, counts, and sum can get you a long way, but R provides many other useful summary functions: