Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
acts-875
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carl Corder
acts-875
Commits
3d601a85
Commit
3d601a85
authored
5 years ago
by
Carl Corder
Browse files
Options
Downloads
Patches
Plain Diff
Update transform_data.r
parent
d8cfffee
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/phase2/transform_data.r
+6
-2
6 additions, 2 deletions
scripts/phase2/transform_data.r
with
6 additions
and
2 deletions
scripts/phase2/transform_data.r
+
6
−
2
View file @
3d601a85
...
...
@@ -3,12 +3,13 @@ library("writexl")
library
(
"dplyr"
)
# Phase 2 Excel
input
<-
"C:/Users/its-student/Desktop/Phase2In.xlsx"
# https://unl.box.com/s/4dfo4iv2n8awiqt20himu24kyhtmgavk
output
<-
"C:/Users/its-student/Desktop/Phase2Out.xlsx"
# https://unl.box.com/s/vyfmeb62bc1umiuuuuj0tkvo2zvp28uq
input
<-
"C:/Users/its-student/Desktop/Phase2In.xlsx"
output
<-
"C:/Users/its-student/Desktop/Phase2Out.xlsx"
# read in sheets
data
<-
read_excel
(
input
,
sheet
=
"Data"
)
commission
<-
read_excel
(
input
,
sheet
=
"Commission"
)
# by group and policy duration
demographic
<-
read_excel
(
input
,
sheet
=
"Demographic"
)
expense
<-
read_excel
(
input
,
sheet
=
"Expense"
)
# bin by annualized net premium
rtn
<-
read_excel
(
input
,
sheet
=
"RTN"
)
sic
<-
read_excel
(
input
,
sheet
=
"SIC"
)
...
...
@@ -23,6 +24,9 @@ data <- merge(x = data, y = sic, by.x = "SIC", by.y = "SIC_CODE", all.x = TRUE)
# remove rows where the sic has no industry (e.g. SIC = 1790)
data
<-
data
%>%
filter
(
!
is.na
(
INDUSTRY
))
# left outer-join on demographics (age, gender, salary)
data
<-
merge
(
x
=
data
,
y
=
demographic
,
by.x
=
"GROUP_ID"
,
by.y
=
"GROUP_ID"
,
all.x
=
TRUE
)
# append percent commission
data
<-
merge
(
x
=
data
,
y
=
commission
[,
c
(
"GROUP_ID"
,
"POLICY_DURATION"
,
"PERCENT_COMMISSION"
)],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment