我是靠谱客的博主 欣喜可乐,最近开发中收集的这篇文章主要介绍R语言:gl()函数,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

gl(base)

gl()所属R语言包:base ;Generate Factor Levels,生成因子水平


Generate factors by specifying the pattern of their levels.
通过指定水平的格局产生的因素。


用法----------Usage----------


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

参数: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.
一个逻辑表明是否排序


返回值为 因子长度从1到n,k为length组复制的每个值。

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


最后

以上就是欣喜可乐为你收集整理的R语言:gl()函数的全部内容,希望文章能够帮你解决R语言:gl()函数所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(53)

评论列表共有 0 条评论

立即
投稿
返回
顶部