Movatterモバイル変換


[0]ホーム

URL:


rdrr.io

gl: Generate Factor Levels

glR Documentation

Generate Factor Levels

Description

Generate factors by specifying the pattern of their levels.

Usage

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

Arguments

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.

Value

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.

See Also

The underlyingfactor().

Examples

## 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)

What can we improve?

R Package Documentation

Browse R Packages

We want your feedback!

Note that we can't provide technical support on individual packages. You should contact the package authors for that.

 
Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, readEmbedding Snippets.

Close

[8]ページ先頭

©2009-2026 Movatter.jp