How to use Summary Function in R? Last Updated : 16 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The summary() function provides a quick statistical overview of a given dataset or vector. When applied to numeric data, it returns the following key summary statistics:Min: The minimum value in the data1st Qu: The first quartile (25th percentile)Median: The middle value (50th percentile)3rd Qu: The third quartile (75th percentile)Max: The maximum value in the dataSyntax:summary(data)Where, data can be a vector, dataframe, etc. In this article, we will explore the summary() function in the R programming language.Using summary() with VectorHere we are going to create a vector with some elements and get the summary statistics using the summary() function. R data = c(1: 5, 56, 43, 56, 78, 51) print(data) print(summary(data)) Output:Using summary() with DataFrameHere we are going to get the summary of all columns in the dataframe. R data = data.frame(col1=c(1: 5, 56, 43, 56, 78, 51), col2=c(100: 104, 56, 43, 56, 78, 51), col3=c(1: 5, 34, 56, 78, 76, 79)) print(data) print(summary(data)) Output:Using summary() with Specific DataFrame ColumnsHere we can get summary of particular columns of the dataframe.Syntax:summary(dataframe[c 1="'column2',..,column" 2="n)" language="('column1',"][/c]) R data = data.frame(col1=c(1: 5, 56, 43, 56, 78, 51), col2=c(100: 104, 56, 43, 56, 78, 51), col3=c(1: 5, 34, 56, 78, 76, 79)) print(data) print(summary(data[c('col1', 'col3')])) Output:Using summary() with Regression ModelHere we can also calculate summary() for linear regression model. We can create an linear regression model for dataframe columns using lm() function.Syntax:summary(lm(column1~column2, dataframe)) R data = data.frame(col1=c(1: 5, 56, 43, 56, 78, 51), col2=c(100: 104, 56, 43, 56, 78, 51)) reg = lm(col1~col2, data) summary(reg) Output:Using summary() with ANOVA ModelHere aov() is used to create ANOVA (Analysis of Variance) model which stands for analysis of variance.Syntax:summary(aov(col1 ~ col2, data))Example: R data = data.frame(col1=c(1: 5, 56, 43, 56, 78, 51), col2=c(100: 104, 56, 43, 56, 78, 51)) reg = aov(col1 ~ col2, data) summary(reg) Output: Comment More infoAdvertise with us Next Article How to use Summary Function in R? M manojkumarreddymallidi Follow Improve Article Tags : R Language R Functions Similar Reads How to Use sum Function in R? In this article, we will discuss how to use the sum() function in the R Programming Language. sum() function: This is used to return the total/sum of the given data Syntax: sum(data) Arguments: data can be a vector or a dataframeExample 1: Using sum() function to calculate the sum of vector elements 5 min read How to Use aggregate Function in R In this article, we will discuss how to use aggregate function in R Programming Language. aggregate() function is used to get the summary statistics of the data by group. The statistics include mean, min, sum. max etc. Syntax: aggregate(dataframe$aggregate_column, list(dataframe$group_column), FUN) 2 min read How to Perform a SUMIF Function in R? In this article, we will discuss the sumif function in R Programming Language. This function is used to group the data and get the sum of the values by a group of values in the dataframe, so we are going to perform this operation on the dataframe. Method 1: Perform a SUMIF Function On One Column: In 3 min read sum() function in R sum() function in R Programming Language returns the addition of the values passed as arguments to the function. Syntax: sum(...) Parameters: ...: numeric or complex or logical vectorssum() Function in R ExampleR program to add two numbersHere we will use sum() functions to add two numbers. R a1=c(1 2 min read How to Create Summary Tables in R? In this article, we will discuss how to create summary tables in R Programming Language. The summary table contains the following information: vars: represents the column numbern: represents the number of valid casesmean: represents the mean valuemedian: represents the median valuetrimmed: represent 4 min read How to View the Source Code for a Function in R? If you're diving into R programming, there will come a time when you want to look under the hood and see how a function works. Maybe you're curious about the mechanics, or you want to understand it better to use it more effectively. Here's a guide to help you view the source code for a function in R 4 min read How to Use do.call in R In R Programming language the do.call() function is used to execute a function call using a list of arguments. This can be particularly useful when we have a function and its arguments stored in separate objects (e.g., in a list) and we want to apply the function to these arguments. Syntax do.call(f 4 min read How to Fix sum Error in R The sum ()' function in the R programming language is required for calculating the total sum of numerical data. Although this function appears easy, a few things can go wrong or provide unexpected outcomes. These errors might be caused by data type errors, incorrect handling of missing values, or a 6 min read How to Calculate Five Number Summary in R? In this article, we will discuss how to calculate five number summary in R programming language. Five number summary is also known as a boxplot. it will return five values that are : The minimum value present in the given dataThe first quartile value present in the given dataThe median  value presen 2 min read How to Use Map Function with the Base R Pipe |> The R Programming Language, widely used for statistical computing and data analysis, has continued to evolve to make coding more efficient and intuitive. One significant advancement in recent versions of R is the introduction of the native pipe operator |>, which allows for a cleaner and more rea 4 min read Like