VOOZH about

URL: https://www.geeksforgeeks.org/r-language/how-to-use-summary-function-in-r/

⇱ How to use Summary Function in R? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to use Summary Function in R?

Last Updated : 23 Jul, 2025

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 data
  • 1st 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 data

Syntax:

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 Vector

Here we are going to create a vector with some elements and get the summary statistics using the summary() function.

Output:

👁 Image

Using summary() with DataFrame

Here we are going to get the summary of all columns in the dataframe.

Output:

👁 Image

Using summary() with Specific DataFrame Columns

Here we can get summary of particular columns of the dataframe.

Syntax:

summary(dataframe[c 1="'column2',..,column" 2="n)" language="('column1',"][/c])

Output:

👁 Image

Using summary() with Regression Model

Here 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))

Output:

👁 Image

Using summary() with ANOVA Model

Here aov() is used to create ANOVA (Analysis of Variance) model which stands for analysis of variance.

Syntax:

summary(aov(col1 ~ col2, data))

Example:

Output:

👁 Image

Comment
Article Tags:

Explore