id: Identification Numbers

Description Usage Arguments Value Warning Note See Also Examples

View source: R/id.R

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

1
2
3
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 r_data_frame or r_list.

random

logical. If TRUE the IDs are randomized, otherwise the IDs are sequential.

name

The name to assign to the output vector's varname attribute. This is used to auto assign names to the column/vector name when used inside of r_data_frame or r_list.

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

sprintf

Examples

1
2
id(1000)
r_data_frame(n=21, id)

wakefield documentation built on May 19, 2018, 5:04 p.m.