Learn R Programming

actuar (version 0.9-3)

grouped.data: 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(..., row.names = NULL, check.rows = FALSE,
             check.names = TRUE)

Arguments

...
these arguments are either of the form value or tag = value. See Details.
row.names, check.rows, check.names
arguments identical to those of data.frame.

Value

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

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.

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

Run this code
## 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)

Run the code above in your browser using DataLab