Learn R Programming

wakefield (version 0.3.9)

id: 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")

Value

Returns a (optionally random) vector of character/factor observations ID numbers.

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.

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.

See Also

Examples

Run this code
id(1000)
r_data_frame(n=21, id)

Run the code above in your browser using DataLab