Compute Summary Statistics of Subsets in R Programming - aggregate() function Last Updated : 01 Jul, 2020 Comments Improve Suggest changes Like Article Like Report In R programming, aggregate() function is used to compute the summary statistics of the split data. It takes the data frame or time series analysis object. Syntax: aggregate(x, by, FUN) Parameters: x: specifies R object by: specifies list of grouping elements FUN: specifies function to compute the statistical summary To know about more optional parameters, use below command in console: help("aggregate") Example 1: r # Using state.x77 and state.region dataset # Compute the mean of the states in state.x77 # grouped by state.region variables aggregate(state.x77, list(region = state.region), mean) Output: region Population Income Illiteracy Life Exp Murder HS Grad Frost Area 1 Northeast 5495.111 4570.222 1.000000 71.26444 4.722222 53.96667 132.7778 18141.00 2 South 4208.125 4011.938 1.737500 69.70625 10.581250 44.34375 64.6250 54605.12 3 North Central 4803.000 4611.083 0.700000 71.76667 5.275000 54.51667 138.8333 62652.00 4 West 2915.308 4702.615 1.023077 71.23462 7.215385 62.00000 102.1538 134463.00 Example 2: r # Using mtcars dataset # Compute the mean of all columns in mtcars # grouped by gears aggregate(mtcars, list(mtcars$gears), mean) Output: Group.1 mpg cyl disp hp drat wt qsec vs am gear carb 1 3 16.10667 7.466667 326.3000 176.1333 3.132667 3.892600 17.692 0.2000000 0.0000000 3 2.666667 2 4 24.53333 4.666667 123.0167 89.5000 4.043333 2.616667 18.965 0.8333333 0.6666667 4 2.333333 3 5 21.38000 6.000000 202.4800 195.6000 3.916000 2.632600 15.640 0.2000000 1.0000000 5 4.400000 Comment More infoAdvertise with us Next Article Compute Summary Statistics of Subsets in R Programming - aggregate() function U utkarsh_kumar Follow Improve Article Tags : R Language R Statistics Similar Reads Create Subsets of a Data frame in R Programming - subset() Function subset() function in R Programming Language is used to create subsets of a Data frame. This can also be used to drop columns from a data frame.Syntax: subset(df, expr)Parameters: df: Data frame usedexpr: Condition for subsetCreate Subsets of Data Frames in R Programming LanguageHere we will make sub 3 min read Compute the Sum of Rows of a Matrix or Array in R Programming - rowSums Function rowSums() function in R Programming Language is used to compute the sum of rows of a matrix or an array. It simplifies the process of calculating the sum for each row, especially when dealing with large datasets, and can be applied to both numeric and logical data types.Syntax:rowSums(x, na.rm = FAL 3 min read Get Summary of Results produced by Functions in R Programming - summary() Function summary() function in R Language is a generic function used to produce result summaries of the results of various model fitting functions. Syntax: summary(object, maxsum) Parameters: object: R object maxsum: integer value which indicates how many levels should be shown for factors Example 1: Python3 2 min read Condense Column Values of a Data Frame in R Programming - summarise() Function summarise() function in R Language is used to condense various values of column of a data frame to one value. Syntax: summarise(x, expr) Parameters: x: Data Frame expr: Operation to condense data Example 1: Python3 1== # R program to condense data # of a data frame # Loading library library(dplyr) # 1 min read Compute Summary Statistics In R Summary statistics provide a concise overview of the characteristics of a dataset, offering insights into its central tendency, dispersion, and distribution. R Programming Language with its variety of packages, offers several methods to compute summary statistics efficiently. Here we'll explore vari 4 min read Like