Automating our work away One consulting firm’s experience with RMarkdown Finbarr Timbers 1
2
Outline 1. About Darkhorse Analytics 2. Problems we faced 3. How we solved those problems 4. How you can improve R(Markdown) adoption 3
4
5
6
Problems 7
Problems 1. It takes a lot of time to replicate, which is a problem when rework happens (>50 slides!). We’ve had 3 month projects with 1 month consumed by rework. 8
Problems 1. It takes a lot of time to replicate, which is a problem when rework happens (>50 slides!). We’ve had 3 month projects with 1 month consumed by rework. 2. All styled differently. We need to edit every plot individually. 9
Problems 1. It takes a lot of time to replicate, which is a problem when rework happens (>50 slides!). We’ve had 3 month projects with 1 month consumed by rework. 2. All styled differently. We need to edit every plot individually. 3. No documentation on how to replicate. 10
Instead? R! 11
What we did: 12
What we did: 1. Use RMarkdown to write template (“best practice”) slides. 13
What we did: 1. Use RMarkdown to write template (“best practice”) slides. 2. Made the slides accessible to the company (we used Git + Bitbucket). 14
What we did: 1. Use RMarkdown to write template (“best practice”) slides. 2. Made the slides accessible to the company (we used Git + Bitbucket). 3. Made it easy to run in other environments (we used installation scripts; moving to Docker) 15
What we did: 1. Use RMarkdown to write template (“best practice”) slides. 2. Made the slides accessible to the company (we used Git + Bitbucket). 3. Made it easy to run in other environments (we used installation scripts; moving to Docker) 4. Iterate (we used Git). 16
What we did: 1. Use RMarkdown to write template (“best practice”) slides. 2. Made the slides accessible to the company (we used Git + Bitbucket) 3. Made it easy to run in other environments (we used installation scripts; moving to Docker) 4. Iterate (we used Git). 5. Publish as a package (yet to happen). 17
R: darkhorse_histogram = function(df, x_var, x_breaks, x_label, y_var, y_breaks, y_label, title, col="#E69F00") { ggplot(df, aes_string(x = x_var, y = y_var)) + ggtitle(title) + geom_bar(fill=col, stat = "identity") + geom_hline(yintercept= 0, colour=col) + darkhorse_theme() + ylab(y_label) + xlab(x_label) + scale_y_continuous(breaks=y_breaks) geom_hline( yintercept=y_breaks[2:length(y_breaks)], color="white") + scale_x_continuous(breaks=x_breaks) } 18
Go from. . . 19
To. . . Part Time Responders 12 Headcount 10 8 6 4 2 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Minutes from Home to Station 20
Also: SQL SELECT * FROM (SELECT CASE WHEN Call_Type NOT IN ('Medical', 'Fire', 'Fire Alarm Ringing ELSE Call_Type END AS CallType, CallID, Year FROM ERA_TFS.dbo.Calls_Template WHERE Qualified_Event = 1) t PIVOT (COUNT(CallID) FOR Year IN ([2012], [2013], [2014])) pvt 21
60000 Medical Calls 40000 Fire Alarm Ringing Other 20000 Fire Vehicle Incident 2012 2013 2014 22
Lessons 1. Make it great. 23
Lessons 1. Make it great. 2. Make it easy. 24
Lessons 1. Make it great. 2. Make it easy. 3. Make it profitable. 25
Recommend
More recommend