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

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:

主站蜘蛛池模板: 谢通门县| 东城区| 青川县| 蒙城县| 杭锦后旗| 长乐市| 广安市| 博湖县| 长子县| 五常市| 芦溪县| 偃师市| 梅河口市| 常山县| 龙江县| 宽城| 深水埗区| 津南区| 抚宁县| 旅游| 景泰县| 延寿县| 平罗县| 左贡县| 揭西县| 蒙城县| 武定县| 福建省| 蓬溪县| 沽源县| 新泰市| 乃东县| 油尖旺区| 鄂托克旗| 保靖县| 且末县| 顺平县| 长子县| 杨浦区| 长葛市| 弥渡县|