partial_relevel: Partially relevel a vector

Description Usage Arguments Value Examples

Description

Turn a vector into a factor vector. The order of the vector is not changed, only the factor level

Usage

1
2
3
4
5
6
7
partial_relevel(
  x,
  reorder_levels = NULL,
  mixed_sorting = F,
  leading_char = "",
  skip_char = 0
)

Arguments

x

a vector

reorder_levels

a vector specifying which celltype should be in the earlier positions of of the factor level. There is no need to specify a string that matches the celltype name exactly. Regular expression will be used to match the string names from the beginning of the strings.

mixed_sorting

if set TRUE, the mixedsort function from gtools package will be used and will override the reorder_levels argument

leading_char

ignore the leading character when releveling

Value

a factor vector

Examples

1
2
3
4
5
6
library (gtools)
reorder_levels <- c('Zy', '4C', '8C') # 'Zy' would be shown first in  the
# factor level, '4C' would be the second etc
celltypes <- c( '4C_D2', '8C_D2', 'Zy_D1' , '4C_D2', 'cMor_D3')
partial_relevel ( celltypes, reorder_levels )
#alternatively you may use the default ordering vector

Yutong441/TBdev documentation built on Dec. 18, 2021, 8:22 p.m.