Commit 03928d02 authored by Carl Corder's avatar Carl Corder
Browse files

write transformed data to excel

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