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

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:

主站蜘蛛池模板: 高要市| 客服| 石景山区| 太仆寺旗| 延长县| 玉环县| 翁源县| 平安县| 永嘉县| 武宁县| 夏邑县| 宕昌县| 扶余县| 桐庐县| 雷州市| 平舆县| 灌阳县| 连州市| 庆云县| 铅山县| 武穴市| 永新县| 昭苏县| 芦山县| 资溪县| 台南县| 元朗区| 合阳县| 江城| 中方县| 桂东县| 根河市| 西乌| 韶关市| 肇州县| 庄浪县| 广昌县| 隆德县| 苍山县| 乌拉特中旗| 玛沁县|