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:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.97.126