id {wakefield} | R Documentation |
Identification Numbers
Description
id
- Generate a sequential character
vector of
zero-padded identification numbers (IDs).
id_factor
- Generate a sequential factor
vector
of zero-padded identification numbers (IDs).
Usage
id(n, random = FALSE, name = "ID")
id_factor(n, random = FALSE, name = "ID")
Arguments
n |
The number elements to generate. This can be globally set within
the environment of |
random |
logical. If |
name |
The name to assign to the output vector's |
Value
Returns a (optionally random) vector of
character
/factor
observations
ID numbers.
Warning
id
uses sprintf
to generate the
padded ID. Per sprintf
's documentation: “The format
string is passed down the OS's sprintf function...The behaviour on inputs not
documented here is 'undefined', which means it is allowed to differ by
platform.” See sprintf
for details.
Note
id
is faster than id_factor
, as the later coerces the
vector to a factor
.
See Also
Examples
id(1000)
r_data_frame(n=21, id)