| gl | R Documentation |
Generate factors by specifying the pattern of their levels.
gl(n, k, length = n*k, labels = seq_len(n), ordered = FALSE)
n | an integer giving the number of levels. |
k | an integer giving the number of replications. |
length | an integer giving the length of the result. |
labels | an optional vector of labels for the resulting factorlevels. |
ordered | a logical indicating whether the result should beordered or not. |
The result has levels from1 ton with each valuereplicated in groups of lengthk out to a total length oflength.
gl is modelled on theGLIM function of the same name.
The underlyingfactor().
## First control, then treatment:gl(2, 8, labels = c("Control", "Treat"))## 20 alternating 1s and 2sgl(2, 1, 20)## alternating pairs of 1s and 2sgl(2, 2, 20)Add the following code to your website.
For more information on customizing the embed code, readEmbedding Snippets.
