ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

aggregate()函数--R语言

2021-04-30 12:31:12  阅读:237  来源: 互联网

标签:函数 -- frame drop FUN each aggregate data


1.函数功能

Splits the data into subsets, computes summary statistics for each, 
and returns the result in a convenient form.

将数据拆分为子集,为每个子集计算摘要统计信息,然后以方便的形式返回结果。

2.函数语法

aggregate(x, by, FUN, ..., simplify = TRUE, drop = TRUE)

3. 函数参数

3.1 x

x	
an R object.

R对象

3.2 by

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.

分组元素的列表,每个与数据框x中的变量长度相同。 使用之前,将这些元素强制转换为因子。

3.3 FUN

FUN	
a function to compute the summary statistics which can be applied to all data subsets.

计算汇总统计信息的函数,FUN(function)

3.4 simplify

simplify	
a logical indicating whether results should be simplified to a vector or matrix if possible.

逻辑值,表明是否应将结果简化为向量或矩阵。

3.5 drop

drop	
a logical indicating whether to drop unused combinations of grouping values. 
The non-default case drop=FALSE has been amended for R 3.5.0 to drop unused combinations.

逻辑值,表明是否删除未使用的分组值组合的逻辑。默认为TRUE

aggregate.data.frame is the data frame method. If x is not a data frame, it is coerced to one, 
which must have a non-zero number of rows. 
Then, each of the variables (columns) in x is split into subsets of cases (rows) of identical combinations of the components of by, 
and FUN is applied to each such subset with further arguments in ... passed to it. 
The result is reformatted into a data frame containing the variables in by and x.

aggregate.data.frame是数据框方法,若x不是数据框,将其转换为数据框,该数据库的行数不为0.
然后,将x中的每个变量(列)划分为by成分完全相同的情况(行)的子集,然后将FUN应用于每个此类子集,并在…中传递进一步的参数。将结果重新格式化为包含by和x中变量的数据框。

在这里插入图片描述

在这里插入图片描述

原文链接: aggregate

标签:函数,--,frame,drop,FUN,each,aggregate,data
来源: https://blog.csdn.net/chongbaikaishi/article/details/116131517

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有