gl package:base R Documentation _G_e_n_e_r_a_t_e _F_a_c_t_o_r _L_e_v_e_l_s _D_e_s_c_r_i_p_t_i_o_n: Generate factors by specifying the pattern of their levels. _U_s_a_g_e: gl(n, k, length = n*k, labels = 1:n, ordered = FALSE) _A_r_g_u_m_e_n_t_s: 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 factor levels. ordered: a logical indicating whether the result should be ordered or not. _V_a_l_u_e: The result has levels from '1' to 'n' with each value replicated in groups of length 'k' out to a total length of 'length'. 'gl' is modelled on the _GLIM_ function of the same name. _S_e_e _A_l_s_o: The underlying 'factor()'. _E_x_a_m_p_l_e_s: ## First control, then treatment: gl(2, 8, labels = c("Control", "Treat")) ## 20 alternating 1s and 2s gl(2, 1, 20) ## alternating pairs of 1s and 2s gl(2, 2, 20)