The “summary” Function in R
Package: Base R (no specific package required)
Purpose: Generates summary statistics of the input data.
General Class: Descriptive Statistics
Required Argument(s):
object: An R object for which a summary is desired. This can be various types of objects, such as vectors, data frames, or statistical models.
Notable Optional Arguments:
...: Additional arguments depending on the class of the object. For example, when the object is a linear model fit, additional arguments can be specified.
digits: The number of digits to print. The default is getOption("digits") - 3.
quantile.type: A string specifying the type of quantile to be computed, with options “7” (default), “1”, “2”, “3”, “4”, “5”, “6”, “8”, “9”, “10”.
Example:
# Example data frame
data <- data.frame(
Age = c(25, 30, 35, 40, 45),
Height = c(160, 170, 165, 175, 180),
Weight = c(55, 70, 60, 80, 75)
)
# Generate summary statistics for the data frame
result <- summary(data)
print(result)In this example, the summary function is used to generate summary statistics for a data frame containing columns Age, Height, and Weight. The result is printed to the console.