ordfactby: Turn a column into an ordered factor

View source: R/ordfactby.R

ordfactbyR Documentation

Turn a column into an ordered factor

Description

Converts a column into an ordered factor.

Usage

ordfactby(data, column, by, ...)

Arguments

data

a data frame or tibble

column

the column to convert to an ordered factor

by

the column used to order column

...

expressions passed to dplyr::filter. Only rows satisfying these expressions are used to order column,

Details

column, by, and ... use tidyselect (e.g. column names do not need to be quoted)

Value

The dataframe with column converted to an ordered factor that is ordered according to by

Examples

library(tidyr)
mtcars$Model <- rownames(mtcars)
ordfactby(mtcars, Model, gear)  #turns column Model into an ordered factor ordered by gear

sustainablefarms/sflddata documentation built on April 19, 2022, 11:19 a.m.