ファクター(factor)を生成する関数(gl)
題名の通り、ファクター(factor)を生成する関数があったんで備忘録的にメモ。
名前はgl関数でたぶんGenerate Levelあたりだろうか。
> # 2レベルのデータを8個ずつ作ってそれぞれを数値じゃなくてCOntrol, Treatと名付ける > gl(2, 8, labels = c("Control", "Treat")) [1] Control Control Control Control Control Control Control Control Treat Treat Treat Treat [13] Treat Treat Treat Treat Levels: Control Treat > # 2レベルのデータを1個ずつ作る(1,2) > # その結果がデータサイズが20個になるまで繰り返し(1,2,1,2,1,2,...) > gl(2, 1, 20) [1] 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 Levels: 1 2 > # その結果がデータサイズが20個になるまで繰り返し(1,1,2,2,1,1,2,2,..) > gl(2, 2, 20) [1] 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 Levels: 1 2