Creation of grouped data objects, from either a provided set of group boundaries and group frequencies, or from individual data using automatic or specified breakpoints.
grouped.data(..., breaks = "Sturges", include.lowest = TRUE, right = TRUE, nclass = NULL, group = FALSE, row.names = NULL, check.rows = FALSE, check.names = TRUE)
arguments of the form
same as for
In the last three cases the number is a suggestion only; the
breakpoints will be set to
logical; indicating if the intervals should be closed on the right (and open on the left) or vice versa.
numeric (integer); equivalent to
logical; an alternative way to force grouping of individual data.
arguments identical to those
A grouped data object is a special form of data frame consisting of one column of contiguous group boundaries and one or more columns of frequencies within each group.
The function can create a grouped data object from two types of arguments.
Group boundaries and frequencies. This is the default mode of
operation if the call has at least two elements in
The first argument will then 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.
Individual data. This mode of operation is active if there
is a single argument in
..., or if either
nclass is specified or
... are first grouped using
hist. If needed, breakpoints are set using the first
NA) frequencies are replaced by zeros, with a
Extraction and replacement methods exist for
objects, but working on non adjacent groups will most likely yield
An object of
c("grouped.data", "data.frame") with
an environment containing the vector
cj of group boundaries.
Vincent Goulet firstname.lastname@example.org, Mathieu Pigeon and Louis-Philippe Pouliot
Klugman, S. A., Panjer, H. H. and Willmot, G. E. (1998), Loss Models, From Data to Decisions, Wiley.
[.grouped.data for extraction and replacement methods.
data.frame for usual data frame creation and
hist for details on the calculation of breakpoints.
## Most common usage using a predetermined set of group ## boundaries and group frequencies. 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) ## Alternative usage with grouping of individual data. grouped.data(x) # automatic breakpoints grouped.data(x, breaks = 7) # forced number of groups grouped.data(x, breaks = c(0,25,75,100)) # specified groups grouped.data(x, y, breaks = c(0,25,75,100)) # multiple data sets ## Not run: ## Providing two or more data sets and automatic breakpoints is ## very error-prone since the range of the first data set has to ## include the ranges of all the other data sets. range(x) range(y) grouped.data(x, y, group = TRUE) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.