官术网_书友最值得收藏!

  • Hands-On Data Science with R
  • Vitor Bianchi Lanzetta Nataraj Dasgupta Ricardo Anjoleto Farias
  • 72字
  • 2021-06-10 19:12:35

Aggregation functions

If, say, we were interested in finding the aggregate values of each Region of the US, we could use aggregate to find the cumulative values on a per region basis. To find the min, max, and mean of each column aggregated by region, we will first add the region value to our DataFrame:

# aggregate 
 
state$Region <- state.region 
ncol(state) 
aggregate(state[,-c(9,10)], by=list(state$Region), mean, na.rm = T) 

Following is the output:

主站蜘蛛池模板: 茶陵县| 五大连池市| 两当县| 洪湖市| 马龙县| 广汉市| 喜德县| 攀枝花市| 额尔古纳市| 菏泽市| 乌拉特中旗| 太仆寺旗| 增城市| 什邡市| 缙云县| 甘洛县| 诸暨市| 沅陵县| 黑水县| 美姑县| 宜良县| 平和县| 通城县| 张家港市| 沿河| 崇义县| 九台市| 郸城县| 神农架林区| 东丽区| 和田市| 保靖县| 镇江市| 贵德县| 海安县| 永川市| 明光市| 金秀| 雷州市| 京山县| 沁阳市|