reorder.data.frame: Reorder Levels of Factor Columns of Data Frames

Description Usage Arguments Value Examples

Description

The gg method acts on the underlying data of the gg object input.

Usage

1
2
## S3 method for class 'data.frame'
reorder(.data, ..., .focus = TRUE)

Arguments

.data

a data frame

...

named arguments of unnamed argument of the form '-col', if named the name should correspond to the column to affect and the value will determine the level's rank. If of form '-col' the level order will be reversed for this variable. the value should be

.focus

filter to apply on the data before applying the operations that will define the factor levels

Value

a data frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(dplyr)
head(levels(factor(starwars$homeworld)))
head(levels(factor(starwars$species)))
levels(factor(starwars$gender))
sw <- reorder(starwars, -gender,
              homeworld = mean(height,na.rm=T),
              species = mean(mass,na.rm=T))
head(levels(sw$homeworld))
head(levels(sw$species))
levels(sw$gender)

moodymudskipper/ggfun documentation built on May 26, 2019, 3:33 p.m.