Summarise Data Cheat Sheet

Summarise data into a single row of values.

dplyr::summarise(iris, avg = mean(Sepal.Length))

Apply the summary function to each column.

dplyr::summarise_each(iris, funs(mean))

Count the number of rows with each unique value of a variable (with or without weights).

dplyr::count(iris, Species, wt = Sepal.Length)

First value of a vector.

dplyr::first

Last value of a vector.

dplyr::last

Nth value of a vector.

dplyr::nth

of values in a vector.

dplyr::n

of distinct values in a vector.

dplyr::n_distinct

Minimum value in a vector.

min

Maximum value in a vector.

max

Mean value of a vector.

mean

Median value of a vector.

median

The variance of a vector.

var

The standard deviation of a vector.

sd

Comments