Skip to content
Snippets Groups Projects
Commit 03928d02 authored by Carl Corder's avatar Carl Corder
Browse files

write transformed data to excel

parent 8cd46513
No related branches found
No related tags found
No related merge requests found
library("readxl")
library("writexl")
library("dplyr")
# Phase 2 Excel
# https://unl.box.com/s/4dfo4iv2n8awiqt20himu24kyhtmgavk
fileName <- "C:/Users/its-student/Desktop/Phase2.xlsx"
input <- "C:/Users/its-student/Desktop/Phase2In.xlsx"
output <- "C:/Users/its-student/Desktop/Phase2Out.xlsx"
# read in sheets
data <- read_excel(fileName, sheet = "Data")
commission <- read_excel(fileName, sheet = "Commission") # by group and policy duration
expense <- read_excel(fileName, sheet = "Expense") # bin by annualized net premium
rtn <- read_excel(fileName, sheet = "RTN")
sic <- read_excel(fileName, sheet = "SIC")
tax <- read_excel(fileName, sheet = "Tax")
data <- read_excel(input, sheet = "Data")
commission <- read_excel(input, sheet = "Commission") # by group and policy duration
expense <- read_excel(input, sheet = "Expense") # bin by annualized net premium
rtn <- read_excel(input, sheet = "RTN")
sic <- read_excel(input, sheet = "SIC")
tax <- read_excel(input, sheet = "Tax")
# drop reserves not related to STD (IBNR)
data <- data %>% select(-c(ICOS, WAIVER_IBNR, GAAP_RESV, WAIVER_RESERVE))
......@@ -97,3 +98,7 @@ data <- data %>% mutate(ACTUAL_CLAIMS = PAID_CLAIMS + IBNR)
# calculate actual to expected ratio
data <- data %>% mutate(ACTUAL_TO_EXPECTED = ACTUAL_CLAIMS / EXPECTED_CLAIMS)
# write data to Excel
write_xlsx(data, path = output, col_names = TRUE)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment