Make New Variables

Compute and append one or more new columns.

dplyr::mutate(iris, sepal = Sepal.Length + Sepal. Width)

Apply the window function to each column.

dplyr::mutate_each(iris, funs(min_rank))

Compute one or more new columns. Drop original columns.

dplyr::transmute(iris, sepal = Sepal.Length + Sepal. Width)

Copy with values shifted by 1.

dplyr::lead

Copy with values lagged by 1.

dplyr::lag

Ranks with no gaps.

dplyr::dense_rank

Ranks. Ties get min rank.

dplyr::min_rank

Ranks rescaled to [0, 1].

dplyr::percent_rank

Ranks. Ties got to first value.

dplyr::row_number

Bin vector into n buckets.

dplyr::ntile

Are values between a and b?

dplyr::between

Cumulative distribution.

dplyr::cume_dist

Cumulative all

dplyr::cumall

Cumulative any

dplyr::cumany

Cumulative mean

dplyr::cummean

Cumulative sum

cumsum

Cumulative max

cummax

Cumulative min

cummin

Cumulative prod

cumprod

Element-wise max

pmax

Element-wise min

pmin

Comments