Create a single panel ID variable out of several
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.
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'
).
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"))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.