splice_color_order: splice color ordering factor to rotate across groups.

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/splice_color_order.R

Description

Takes equal-length factors for group membership and ID value (nested within group membership) and returns a new factor ordering more evenly across groups. E.g., for "K" groups, the first level is the first ID in group #1, second level is the first ID in group #2, ..., the K'th level is the first ID in group #K, then the (K+1)st level is the second ID in group #1, and so on. The logic of the algorithm assumes that

Usage

1
splice_color_order(group, ID, as_factor = TRUE)

Arguments

group

factor denoting group membership.

ID

factor denoting identification. Levels must be nested within group (i.e., an ID cannot be listed in 2+ different groups).

as_factor

logical return the result as a factor (the default) or, as an alternative, return the whole data frame.

Details

identical( dat, dat[ order( group, ID ),] )

is TRUE, since this is the use case within which it was developed, and otherwise it's ambiguous what a user would expect. The function will still run if this condition fails, but a warning is issued and results are unpredictable.

Value

a factor

Author(s)

Bill Forrest forrest@gene.com

See Also

factor

Examples

1
2
3
 my_group <- factor( rep(paste('group',lead_char(1:3),sep = '_'),each = 4) )
 my_ID    <- factor( paste('ID',lead_char(1:12), sep = '_') )
 my_color_order <- splice_color_order ( my_group, my_ID )

wfforrest/maeve documentation built on Jan. 1, 2021, 12:47 p.m.