美文网首页
20190428-R语言循环函数aggregate、by

20190428-R语言循环函数aggregate、by

作者: 天空的小白 | 来源:发表于2019-04-28 10:26 被阅读0次

-Usage
aggregate(x, by, FUN, ..., simplify = TRUE, drop = TRUE)
与tapply类似,但是x可以为data.frame或矩阵;
-Arguments
by
a list of grouping elements, each as long as the variables in the data frame x. The
elements are coerced to factors before use.
-Example


testDF
Vby1
by2
aggregate

-Usage
by(data, INDICES, FUN, ..., simplify = TRUE);
-Example
将warpbreaks的一二列,根据tension这一列的(L、M、H)运行summary

warpbreaks
by

aggregate与by的区别:aggregate是对x的每一列分别根据因子进行分组计算,而by是根据因子将data整个分成几个小的data.frame,然后进行运算;

相关文章

网友评论

      本文标题:20190428-R语言循环函数aggregate、by

      本文链接:https://www.haomeiwen.com/subject/vpahnqtx.html