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

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:

主站蜘蛛池模板: 鄱阳县| 中山市| 凯里市| 江川县| 原平市| 临颍县| 古浪县| 康平县| 老河口市| 陕西省| 东山县| 孝昌县| 牡丹江市| 常熟市| 衡阳市| 丹江口市| 西平县| 建瓯市| 浮梁县| 南京市| 交口县| 晋中市| 尖扎县| 微山县| 临城县| 花莲县| 会同县| 于都县| 禹城市| 公主岭市| 盐山县| 玉溪市| 天台县| 吴堡县| 古田县| 青海省| 大城县| 腾冲县| 凌海市| 会泽县| 塔河县|