View source: R/pwutilityfunctions.R
char2sorted_factor | R Documentation |
Sorting is carried out using "human" criteria with gtools::mixedsort. Useful with e.g., ggplot or tidyr::spread
char2sorted_factor(charvec, ...)
charvec |
A character vector |
... |
Further arguments to gtools::mixedsort |
Sorted factor
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.