Statistics Made Easy

## How to Use summary() Function in R (With Examples)

This syntax uses the following basic syntax:

The following examples show how to use this function in practice.

## Example 1: Using summary() with Vector

The following code shows how to use the summary() function to summarize the values in a vector:

The summary() function automatically calculates the following summary statistics for the vector:

- Min: The minimum value
- 1st Qu: The value of the 1st quartile (25th percentile)
- Median: The median value
- 3rd Qu: The value of the 3rd quartile (75th percentile)
- Max: The maximum value

## Example 2: Using summary() with Data Frame

## Example 3: Using summary() with Specific Data Frame Columns

## Example 4: Using summary() with Regression Model

Related: How to Interpret Regression Output in R

## Example 5: Using summary() with ANOVA Model

Related: How to Interpret ANOVA Results in R

## Additional Resources

The following tutorials offer more information on calculating summary statistics in R:

## Published by Zach

Your email address will not be published. Required fields are marked *

## summary: Object Summaries

# S3 method for factor summary(object, maxsum = 100, …)

# S3 method for matrix summary(object, …)

an object for which a summary is desired.

a result of the default method of summary() .

integer, indicating how many levels should be shown for factor s.

integer code used in quantile(*, type=quantile.type) for the default method.

additional arguments affecting the summary produced.

Chambers, J. M. and Hastie, T. J. (1992) Statistical Models in S . Wadsworth & Brooks/Cole.

anova , summary.glm , summary.lm .

Run the code above in your browser using DataCamp Workspace

- Data Structure & Algorithm Classes (Live)
- System Design (Live)
- DevOps(Live)
- Explore More Live Courses
- Interview Preparation Course
- Data Science (Live)
- GATE CS & IT 2024
- Data Structure & Algorithm-Self Paced(C++/JAVA)
- Data Structures & Algorithms in Python
- Explore More Self-Paced Courses
- C++ Programming - Beginner to Advanced
- Java Programming - Beginner to Advanced
- C Programming - Beginner to Advanced
- Android App Development with Kotlin(Live)
- Full Stack Development with React & Node JS(Live)
- Java Backend Development(Live)
- React JS (Basic to Advanced)
- JavaScript Foundation
- Complete Data Science Program(Live)
- Mastering Data Analytics
- CBSE Class 12 Computer Science
- School Guide
- All Courses
- Linked List
- Binary Tree
- Binary Search Tree
- Advanced Data Structure
- All Data Structures
- Asymptotic Analysis
- Worst, Average and Best Cases
- Asymptotic Notations
- Little o and little omega notations
- Lower and Upper Bound Theory
- Analysis of Loops
- Solving Recurrences
- Amortized Analysis
- What does 'Space Complexity' mean ?
- Pseudo-polynomial Algorithms
- Polynomial Time Approximation Scheme
- A Time Complexity Question
- Searching Algorithms
- Sorting Algorithms
- Graph Algorithms
- Pattern Searching
- Geometric Algorithms
- Mathematical
- Bitwise Algorithms
- Randomized Algorithms
- Greedy Algorithms
- Dynamic Programming
- Divide and Conquer
- Backtracking
- Branch and Bound
- All Algorithms
- Company Preparation
- Practice Company Questions
- Interview Experiences
- Experienced Interviews
- Internship Interviews
- Competitive Programming
- Design Patterns
- System Design Tutorial
- Multiple Choice Quizzes
- Go Language
- Tailwind CSS
- Foundation CSS
- Materialize CSS
- Semantic UI
- Angular PrimeNG
- Angular ngx Bootstrap
- jQuery Mobile
- jQuery EasyUI
- React Bootstrap
- React Rebass
- React Desktop
- React Suite
- ReactJS Evergreen
- ReactJS Reactstrap
- BlueprintJS
- TensorFlow.js
- English Grammar
- School Programming
- Number System
- Trigonometry
- Probability
- Mensuration
- Class 8 Syllabus
- Class 9 Syllabus
- Class 10 Syllabus
- Class 8 Notes
- Class 9 Notes
- Class 10 Notes
- Class 11 Notes
- Class 12 Notes
- Class 8 Maths Solution
- Class 9 Maths Solution
- Class 10 Maths Solution
- Class 11 Maths Solution
- Class 12 Maths Solution
- Class 7 Notes
- History Class 7
- History Class 8
- History Class 9
- Geo. Class 7
- Geo. Class 8
- Geo. Class 9
- Civics Class 7
- Civics Class 8
- Business Studies (Class 11th)
- Microeconomics (Class 11th)
- Statistics for Economics (Class 11th)
- Business Studies (Class 12th)
- Accountancy (Class 12th)
- Macroeconomics (Class 12th)
- Machine Learning
- Data Science
- Mathematics
- Operating System
- Computer Networks
- Computer Organization and Architecture
- Theory of Computation
- Compiler Design
- Digital Logic
- Software Engineering
- GATE 2024 Live Course
- GATE Computer Science Notes
- Last Minute Notes
- GATE CS Solved Papers
- GATE CS Original Papers and Official Keys
- GATE CS 2023 Syllabus
- Important Topics for GATE CS
- GATE 2023 Important Dates
- Software Design Patterns
- HTML Cheat Sheet
- CSS Cheat Sheet
- Bootstrap Cheat Sheet
- JS Cheat Sheet
- jQuery Cheat Sheet
- Angular Cheat Sheet
- Facebook SDE Sheet
- Amazon SDE Sheet
- Apple SDE Sheet
- Netflix SDE Sheet
- Google SDE Sheet
- Wipro Coding Sheet
- Infosys Coding Sheet
- TCS Coding Sheet
- Cognizant Coding Sheet
- HCL Coding Sheet
- FAANG Coding Sheet
- Love Babbar Sheet
- Mass Recruiter Sheet
- Product-Based Coding Sheet
- Company-Wise Preparation Sheet
- Array Sheet
- String Sheet
- Graph Sheet
- ISRO CS Original Papers and Official Keys
- ISRO CS Solved Papers
- ISRO CS Syllabus for Scientist/Engineer Exam
- UGC NET CS Notes Paper II
- UGC NET CS Notes Paper III
- UGC NET CS Solved Papers
- Campus Ambassador Program
- School Ambassador Program
- Geek of the Month
- Campus Geek of the Month
- Placement Course
- Testimonials
- Student Chapter
- Geek on the Top
- Geography Notes
- History Notes
- Science & Tech. Notes
- Ethics Notes
- Polity Notes
- Economics Notes
- UPSC Previous Year Papers
- SSC CGL Syllabus
- General Studies
- Subjectwise Practice Papers
- Previous Year Papers
- SBI Clerk Syllabus
- General Awareness
- Quantitative Aptitude
- Reasoning Ability
- SBI Clerk Practice Papers
- SBI PO Syllabus
- SBI PO Practice Papers
- IBPS PO 2022 Syllabus
- English Notes
- Reasoning Notes
- Mock Question Papers
- IBPS Clerk Syllabus
- Apply for a Job
- Apply through Jobathon
- Hire through Jobathon
- All DSA Problems
- Problem of the Day
- GFG SDE Sheet
- Top 50 Array Problems
- Top 50 String Problems
- Top 50 Tree Problems
- Top 50 Graph Problems
- Top 50 DP Problems
- Solving For India-Hackthon
- GFG Weekly Coding Contest
- Job-A-Thon: Hiring Challenge
- BiWizard School Contest
- All Contests and Events
- Saved Videos
- What's New ?
- Data Structures
- Interview Preparation
- Topic-wise Practice
- Latest Blogs
- Write & Earn
- Web Development

## Related Articles

- Write Articles
- Pick Topics to write
- Guidelines to Write
- Get Technical Writing Internship
- Write an Interview Experience
- Change column name of a given DataFrame in R
- Convert Factor to Numeric and Numeric to Factor in R Programming
- Adding elements in a vector in R programming - append() method
- Clear the Console and the Environment in R Studio
- Printing Output of an R Program
- Comments in R
- How to Replace specific values in column in R DataFrame ?
- Creating a Data Frame from Vectors in R Programming
- Filter data by multiple conditions in R using Dplyr
- How to change Row Names of DataFrame in R ?
- Loops in R (for, while, repeat)
- R Programming Language - Introduction
- Taking Input from User in R Programming
- Change Color of Bars in Barchart using ggplot2 in R
- Remove rows with NA in one column of R DataFrame
- Converting a List to Vector in R Language - unlist() Function
- Group by function in R using Dplyr
- How to Change Axis Scales in R Plots?
- Inverse of Matrix in R
- K-Means Clustering in R Programming
- Logistic Regression in R Programming
- How to Split Column Into Multiple Columns in R DataFrame?
- Skewness and Kurtosis in R Programming
- Calculate Time Difference between Dates in R Programming - difftime() Function
- How to filter R dataframe by multiple conditions?
- Cross-Validation in R programming
- Convert String from Uppercase to Lowercase in R programming - tolower() method
- Matrix Multiplication in R
- Reading Files in R Programming
- How to filter R DataFrame by values in a column?

## Get Summary of Results produced by Functions in R Programming – summary() Function

Syntax: summary(object, maxsum) Parameters: object: R object maxsum: integer value which indicates how many levels should be shown for factors

## Please Login to comment...

## Improve your Coding Skills with Practice

Start your coding journey now.

## What is the summarize() method in R?

## Summarize grouped data

The operations that can be performed on grouped data are average , factor , count , mean , etc.

## Summarize ungrouped data

We can also summarize ungrouped data. This can be done by using three functions.

## 1. summarize_all()

This function summarizes all the columns of data based on the action which is to be performed.

## 2. summarize_at()

It performs the action on the specific column and generates the summary based on that action.

## 3. summarize_if()

A predicate function in R returns only True/False.

In the code snippet below, we use the predicate function is.numeric and mean as an action.

Learn in-demand tech skills in half the time

Copyright © 2023 Educative, Inc. All rights reserved.

## How to Compute Summary Statistics by Group in R (3 Examples)

This page shows how to calculate descriptive statistics by group in R .

The article contains the following topics:

If you want to know more about these topics, keep reading!

## Construction of Example Data

First, we’ll need to create some exemplifying data:

## Example 1: Descriptive Summary Statistics by Group Using tapply Function

## Example 2: Descriptive Summary Statistics by Group Using dplyr Package

First, we have to install and load the dplyr package:

install.packages("dplyr") # Install dplyr package library("dplyr") # Load dplyr package

Now, we can apply the group_by and summarize functions to calculate summary statistics by group:

## Example 3: Descriptive Summary Statistics by Group Using purrr Package

We first have to install and load the purrr package:

install.packages("purrr") # Install & load purrr library("purrr")

Again, the values are basically the same.

## Video, Further Resources & Summary

If you accept this notice, your choice will be saved and the page will refresh.

Subscribe to the Statistics Globe Newsletter

## 4 Comments . Leave new

## Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

## Statistics Globe Newsletter

## Related Tutorials

## R dplyr group_by & summarize Functions don’t Work Properly (Example)

## summary Function in R (3 Examples)

## Object Summaries

Chambers, J. M. and Hastie, T. J. (1992) Statistical Models in S . Wadsworth & Brooks/Cole.

anova , summary.glm , summary.lm .

## What is summary() Function in R

The summary() function returns the following statistics.

- Minimum value
- The first quartile (25th percentile)
- Median (50th percentile)
- Third quartile (75th percentile)
- Maximum value

object: It is an object for which a summary is desired.

maxsum: An integer indicates how many levels should be shown for factors.

digits: An integer used for number formatting with signif().

## Return Value

The summary() function returns the value that depends on the class of its argument.

## Example 1: Simple use of summary() function

Let’s apply the summary() function to a vector that will act like the R object.

## Example 2: How to get the summary() of list in R

## Example 3: How to get a summary of an array in R

## Example 4: How to get a summary() of the matrix in R

## Example 5: How to get a summary of a data frame in R

## Example 6: Applying a summary() function on Linear Regression Model

That’s it for the summary() function in R.

## Leave a Comment Cancel reply

Save my name, email, and website in this browser for the next time I comment.

## Privacy Overview

## R news and tutorials contributed by hundreds of R bloggers

R tutorial series: summary and descriptive statistics.

Posted on November 1, 2009 by John M. Quick in R bloggers | 0 Comments

## Tutorial Files

> #calculate the mean of a variable with mean(VAR) > #what is the mean Age in the sample? > mean(Age) [1] 32.3 > #calculate the mean of all variables in a dataset with mean(DATAVAR) > #what is the mean of each variable in the dataset? > mean(dataset) Age…… Income 32.3….. 34000.0

## Standard Deviation

> #calculate the standard deviation of a variable with sd(VAR) > #what is the standard deviation of Age in the sample? > sd(Age) [1] 19.45602 > #calculate the standard deviation of all variables in a dataset with sd(DATAVAR) > #what is the standard deviation of each variable in the dataset? > sd(dataset) Age………….. Income 19.45602…. 32306.10175

## Minimum and Maximum

> #calculate the min of a variable with min(VAR) > #what is the minimum age found in the sample? > min(Age) [1] 5 > #calculate the max of a variable with max(VAR) > #what is the maximum age found in the sample? > max(Age) [1] 70

> #calculate the range of a variable with range(VAR) > #what range of age values are found in the sample? > range(Age) [1] 5….70

## Percentiles

Values from percentiles (quantiles).

> #calculate desired percentile values using quantile(VAR, c(PROB1, PROB2,…)) > #what are the 25th and 75th percentiles for age in the sample? > quantile(Age, c(0.25, 0.75)) 25%……. 75% 17.75….. 44.25

> #calculate the default percentile values using quantile(VAR) > #what are the 0, 25, 50, 75, and 100 percentiles for age in the sample? > quantile(Age) 0%…… 25%…… 50%…… 75%…… 100% 5.00… 17.75…… 30.00… 44.25….. 70.00

## Percentiles from Values (Percentile Rank)

- count the number of data points that are at or below the given value
- divide by the total number of data points
- multiply by 100

> #calculate the percentile rank for a given value using the custom formula: length(VAR[VAR <> > #in the sample, an age of 45 is at what percentile rank? > length(Age[Age [1] 75

> #summarize a variable with summary(VAR) > summary(Age)

The output of the preceding summary is pictured below.

> #summarize a dataset with summary(DATAVAR) > summary(dataset)

## Complete Summary Statistics Analysis

## Up Next: Zero-Order Correlations

Copyright © 2022 | MH Corporate basic by MH Themes

## IMAGES

## VIDEO

## COMMENTS

The summary() function in R can be used to quickly summarize the values in a vector, data frame, regression model, or ANOVA model in R.

summary is a generic function used to produce result summaries of the results of various model fitting functions. The function invokes particular methods which

summary() function in R Language is a generic function used to produce result summaries of the results of various model fitting functions.

The summarize() function is used in the R program to summarize the data frame into just one value or vector. This summarization is done through grouping

Definition: The summary R function computes summary statistics of data and model objects. Basic R Syntax: Please find the basic R programming syntax of the

Example 1: Descriptive Summary Statistics by Group Using tapply Function ... The output of the previous R syntax is a list containing one list element for each

Summarize Function in R Programming ... As its name implies, the summarize function reduces a data frame to a summary of just one vector or value.

summary is a generic function used to produce result summaries of the results of various model fitting functions. The function invokes particular methods which

What is summary() Function in R ... The summarize() is a built-in R function for data summarization. It allows developers to reduce a data frame

A very useful multipurpose function in R is summary(X), where X can be one of any number of objects, including datasets, variables, and linear