[ top | up ]

Generate Factor Levels

Syntax

gl(n, k, units=units(), labels=1:n, ordered=false)
units(nunits)

Description

gl generates factors by specifying the pattern of their levels. The result has levels from 1 to n with each value replicated in groups of length k out to a total length of units. Labels for the resulting factor levels can be optionally specified with the arguments labels and the factor levels can be made ordered by specifying ordered=true.

The function units can be used to declare a default value for the length of the resulting factor.

gl is modelled on the Glim function of the same name.