View source: R/S03_Utilities.R
group_index | R Documentation |
Create a numeric index over the unique levels of a variable or a set of variables.
group_index(..., levels = NULL)
... |
Vectors of equal length. |
levels |
A list with the order of the unique levels for each input vector (indices assigned from first to last level). |
An integer vector from 1 to the number of unique levels.
# Convert to numeric index
group_index( rep( LETTERS[3:1], each = 3 ) )
# Can control assignment of indices
group_index(
rep( LETTERS[3:1], each = 3 ), levels = list( c( 'C', 'B', 'A' ) )
)
# Can create single index over all
# unique combinations of multiple variables
group_index( rep( LETTERS[1:3], each = 3 ), rep( 1:3, 3 ) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.