Description Usage Arguments Details Examples
The pmdplyr library accepts the use of multiple ID variables. However, you may wish to combine these into a single variable, or renumber the single variable you already have for some reason.
1 | id_variable(..., .method = "number", .minwidth = FALSE)
|
... |
variables (vectors) that, together, make up the ID variables in the data and uniquely identifies the individual. Note that |
.method |
Can be |
.minwidth |
If |
By default, id_variable() will create a unique numeric identifier out of your ID variables, sequential following the order in the original data (.method='number'
). However, you may want to remove the ordering and assign IDs randomly (.method='random'
), or preserve all the original information and create a single fixed-width character ID variable that contains all the original information (.method='character'
).
1 2 3 4 5 | data(SPrail)
# I want to identify observations at the route (origin-destination)/year level
# Let's make it a character variable so we can tell at a glance what route we're talking
SPrail <- SPrail %>%
dplyr::mutate(route_id = id_variable(origin, destination, .method = "character"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.