# summary() Function in R

summary() function calculates summary statistics of data frames, lists, and matrices. It takes in an array and returns a vector containing summary statistics: mean, median, quartiles, and minimum & maximum values. summary() function in R is a quick and easy way to get an overview of your data. This guide shows you how to use the summary() function in R.

#### Syntax

``summary(object)``

#### Argument

• object = name of any R object like vector, data frame, list, or matrices.

### Example 1: Using summary() with a Vector

The following data set contains the weights of five people.

``````weight <- c(75,67,71,56,68)
summary(weight)``````

#### Output

In this example, there are five observations in the data set. The minimum weight is 56, the 1st quartile is 67, the median is 68, the mean is 67.4, the 3rd quartile is 71, and the maximum weight is 75.

### Example 2: Using summary() with a Data frame

The following data set contains the weights of five people.

``````#creating a data frame
marks <- data.frame(
RollNo = c(1,2,3,4,5,6,7,8,9,10),
science_marks = c(60,70,50,80,60,80,90,50,40,70),
maths_marks = c(70,80,90,60,50,40,30,20,10,0)
)
#calculating summary of data frame
summary(marks)``````

#### Output

We can see from the output that the summary() function gives us the minimum, maximum, mean, median, and first and third quartiles for each column in the data frame.