summary( )
Summarize an object. summary() is a generic function in base R.
Required Library
# summary() is in base R, loaded by default — no package installation neededSyntax
summary(object, ...)summary(object) returns a compact summary of an object. Because summary() is generic, output depends on the class of the object.
summary() dispatches different methods based on object type.
- Numeric vector: min, quartiles, median, mean, max
- Data frame: summary for each column
- Linear model (
lm): residuals, coefficients, residual standard error, R-squared, F-statistic
Examples
Summarize a numeric vector
Summarize each column in a data frame
Summarize an lm() model and extract R-squared
Compare summary() and coef() for a model
Argument Overview
Required arguments must be included when using a function while optional arguments can be included on demand.
object — object to summarize any R object Required
The object for which summary information should be produced.
summary(x)
summary(df)
summary(model)Data Types: numeric, factor, data frame, model object, and many others
… — method-specific options various Optional
Additional arguments passed to class-specific summary methods. Most common beginner use is simply summary(object) with no extra arguments.
Data Types: depends on object class