grouped.data {actuar}R Documentation

Grouped data

Description

Creation of grouped data objects, allowing for consistent representation and manipulation of data presented in a frequency per group form.

Usage

grouped.data(..., right = TRUE, row.names = NULL, check.rows = FALSE,
             check.names = TRUE)

Arguments

... these arguments are either of the form value or tag = value. See Details.
right logical, indicating if the intervals should be closed on the right (and open on the left) or vice versa.
row.names, check.rows, check.names arguments identical to those of data.frame.

Details

A grouped data object is a special form of data frame consisting of:

  1. one column of contiguous group boundaries;
  2. one or more columns of frequencies within each group.

The first argument will be taken as the vector of group boundaries. This vector must be exactly one element longer than the other arguments, which will be taken as vectors of group frequencies. All arguments are coerced to data frames.

Missing (NA) frequencies are replaced by zeros, with a warning.

Extraction and replacement methods exist for grouped.data objects, but working on non adjacent groups will most likely yield useless results.

Value

An object of class c("grouped.data", "data.frame") with an environment containing the vector cj of group boundaries.

Author(s)

Vincent Goulet vincent.goulet@act.ulaval.ca, Mathieu Pigeon and Louis-Philippe Pouliot

References

Klugman, S. A., Panjer, H. H. and Willmot, G. E. (1998), Loss Models, From Data to Decisions, Wiley.

See Also

[.grouped.data for extraction and replacement methods, data.frame for usual data frame creation and manipulation.

Examples

## Most common usage
cj <- c(0, 25, 50, 100, 250, 500, 1000)
nj <- c(30, 31, 57, 42, 45, 10)
(x <- grouped.data(Group = cj, Frequency = nj))
class(x)

x[, 1] # group boundaries
x[, 2] # group frequencies

## Multiple frequency columns are supported
x <- sample(1:100, 9)
y <- sample(1:100, 9)
grouped.data(cj = 1:10, nj.1 = x, nj.2 = y)

[Package actuar version 1.0-2 Index]