as.LongTriangle: Convert Triangle from wide to long

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Given a Triangle in matrix ("wide") format, convert to data.frame ("long") format.

Usage

1
2
as.LongTriangle(Triangle, varnames = names(dimnames(Triangle)), 
                value.name = "value", na.rm = TRUE)

Arguments

Triangle

a loss "triangle". Must be a matrix.

varnames

character names for the columns that will store the rownames and colnames of matrix Triangle. Defaults to names(dimnames(Triangle)) if available. If not provided, uses c("origin", "dev").

value.name

column name to be given to the matrix values that will be stored in the data.frame. Defaults to "value".

na.rm

should NA values be excluded from the data.frame? Defaults to TRUE.

Details

Unlike the as.data.frame.triangle method, and Unlike the 'melt' method in the 'reshape2' package, this function returns a data.frame where the rownames and colnames of Triangle are stored as factors. This can be a critical feature when the order of the levels of the columns is important. For example, when a Triangle is plotted, the order of the origin and dev dimensions is important. See Examples section.

Value

A data.frame.

Author(s)

Daniel Murphy

See Also

as.data.frame.triangle

Examples

1
2
3
4
5
6
as.LongTriangle(GenIns)
## Not run: 
ggplot(as.LongTriangle(GenIns), 
       aes(x = dev, y = value, group = origin, color = origin)) + geom_line()

## End(Not run)

edalmoro/ChainLadderQuantileV1 documentation built on May 29, 2019, 3:05 a.m.