-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCasColNames.R
62 lines (58 loc) · 2 KB
/
CasColNames.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#' CAS Column Names
#' @name CasColNames
#'
#' @description This will change the column names of a data frame obtained from the CAS database of reserve triangles. This data was
#' procured and modified by Glenn G. Meyers and Peng Shi and is hosted by the CAS. More information on the data is available here:
#' \href{http://www.casact.org/research/index.cfm?fa=loss_reserves_data}{http://www.casact.org/research/index.cfm?fa=loss_reserves_data}
#'
#' @param df A data frame of loss reserving data
#' @param restore Boolean indicating whether to restore the names defined by Meyers and Shi. The default is true.
#'
#' @return A data frame with different column names.
#'
#' @export
#'
#' @examples
#'
#' \dontrun{
#' data(NJM_WC)
#' NJM_WC <- CasColNames(NJM_WC, restore = TRUE)
#' }
#'
CasColNames <- function(df, restore = TRUE){
NewColnames <- c("GroupCode"
, "Company"
, "AccidentYear"
, "DevelopmentYear"
, "Lag"
, "CumulativeIncurred"
, "CumulativePaid"
, "IBNR"
, "DirectEP"
, "CededEP"
, "NetEP"
, "Single"
, "Reserve1997")
OldColnames <- c("GRCODE"
, "GRNAME"
,"AccidentYear"
, "DevelopmentYear"
, "DevelopmentLag"
, "IncurLoss_D"
, "CumPaidLoss_D"
, "BulkLoss_D"
, "EarnedPremDIR_D"
, "EarnedPremCeded_D"
, "EarnedPremNet_D"
, "Single"
, "PostedReserve97_D")
if (restore){
names(df) <- OldColnames
} else {
names(df) <- NewColnames
}
df
}