char2sorted_factor: Converts character vector to sorted factor

View source: R/pwutilityfunctions.R

char2sorted_factorR Documentation

Converts character vector to sorted factor

Description

Sorting is carried out using "human" criteria with gtools::mixedsort. Useful with e.g., ggplot or tidyr::spread

Usage

char2sorted_factor(charvec, ...)

Arguments

charvec

A character vector

...

Further arguments to gtools::mixedsort

Value

Sorted factor

Examples

df <- dplyr::data_frame(cells=paste0("cell", 1:15), vals=1:15)
df %>% tidyr::spread(cells, vals)
df %>% dplyr::mutate(cells=char2sorted_factor(cells)) %>%
tidyr::spread(cells, vals)


powestermark/pwrutilities documentation built on Dec. 28, 2024, 4:44 a.m.