Summary
Summary Group Generic Function and Group Method

Description

The Summary Function group is a group of functions for calculating mathematical summaries. Methods can be written for the whole group or individual functions for arbitrary classes. That is, you can write a method for any or all of the functions in the group, or write a single method for the group as a whole.

Usage

Summary(x, ..., na.rm = FALSE)
Summary.factor(..., na.rm)  
Summary.ordered(..., na.rm)  
Summary.data.frame(..., na.rm)

Arguments

x the object used to dispatch to the appropriate Summary group method.
... further arguments to be passed to the group method.
na.rm a logical flag. If TRUE, indicates that NAs should be removed for the summary. The default is FALSE.

Details

Summary A group generic function. This function generates an error if it is called directly. The functions in the group (sum, prod, max, min, range, any, and all) should be called instead. You can find the current list of functions in this group by calling getGroupMembers("Summary").
Summary.factor A group S3 method for class factor. It always generates an error, because all Summary Group functions require an orderable or logical object as an argument. This method exists because it is necessary to prevent interpretation of factors as numeric objects.
Summary.ordered A method to allow the min, max, and range functions to work on ordered factors. Because they have an order, these functions make sense.
Summary.data.frame A group S3 method for the class data.frame. This is a group method for the functions of the Summary group, which all return a single numeric summary of their (numeric) arguments. This method produces an error if any of the input arguments have columns that are not numeric.
Value
returns a single value: the result of applying the summary to all the values of x and ....
Note
The mean and median functions are not part of the Summary group.
See Also
Math, Ops, sum, prod, max, min, range, any, all
Examples
# The Summary group of generic functions includes: 
#   Sums & Products        sum, prod 
#   Extremes               max, min, range
#   Logical Sum & Product  any, all 
x <- runif(20)
sum(x)
max(x[1:6])
all(x)
try(Summary(x)) # Error: function 'Summary' is a group generic; do not call it directly

try(sum(factor(x))) # Error: sum not meaningful for factors try(all(factor(x))) # Error: all not meaningful for factors

Size <- ordered(c("Medium", "Small"), levels=c("Small", "Medium", "Large")) range(Size)

y <- data.frame(matrix(c(2, 4, 3, 9, 21, NA, 6, 4, 9, 10, NA, 7), nrow = 3)) prod(y) sum(y, na.rm = TRUE) min(y, na.rm = TRUE) max(y, data.frame(x=1:100), na.rm = TRUE)

getGroupMembers("Summary") # list all Summary group functions

Package base version 6.1.1-7
Package Index