R - gl(): generate factor levels

02 Dec 2017

Use gl to generate factors by specifying the pattern of their levels.

gl(n, k, length = n*k, labels = seq_len(n), ordered = FALSE)

# n -> number of levels
# k -> number of replications
[ R  function  factor  ]