EVOLUTION-MANAGER
Edit File: gl.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Generate Factor Levels</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for gl {base}"><tr><td>gl {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Generate Factor Levels</h2> <h3>Description</h3> <p>Generate factors by specifying the pattern of their levels. </p> <h3>Usage</h3> <pre> gl(n, k, length = n*k, labels = seq_len(n), ordered = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>n</code></td> <td> <p>an integer giving the number of levels.</p> </td></tr> <tr valign="top"><td><code>k</code></td> <td> <p>an integer giving the number of replications.</p> </td></tr> <tr valign="top"><td><code>length</code></td> <td> <p>an integer giving the length of the result.</p> </td></tr> <tr valign="top"><td><code>labels</code></td> <td> <p>an optional vector of labels for the resulting factor levels.</p> </td></tr> <tr valign="top"><td><code>ordered</code></td> <td> <p>a logical indicating whether the result should be ordered or not.</p> </td></tr> </table> <h3>Value</h3> <p>The result has levels from <code>1</code> to <code>n</code> with each value replicated in groups of length <code>k</code> out to a total length of <code>length</code>. </p> <p><code>gl</code> is modelled on the <em>GLIM</em> function of the same name. </p> <h3>See Also</h3> <p>The underlying <code><a href="factor.html">factor</a>()</code>. </p> <h3>Examples</h3> <pre> ## 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) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>