Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Carl Corder
acts-875
Commits
03928d02
Commit
03928d02
authored
Oct 10, 2019
by
Carl Corder
Browse files
write transformed data to excel
parent
8cd46513
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/phase2/transform_data.r
View file @
03928d02
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/Phase2
Out
.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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment