Slide 1

Slide 1 text

Dr Henry Partridge Greater Manchester Public Health Intelligence Network Session R Trafford Data Lab Manager 22 March 2019

Slide 2

Slide 2 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session • Studied history, philosophy and crime science • Data analyst in public sector • Used R since 2013 Hello

Slide 3

Slide 3 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session Why use R?

Slide 4

Slide 4 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session

Slide 5

Slide 5 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session Open

Slide 6

Slide 6 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session Shareable

Slide 7

Slide 7 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session Human readable

Slide 8

Slide 8 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session Diffable

Slide 9

Slide 9 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session Community driven

Slide 10

Slide 10 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session Supportive

Slide 11

Slide 11 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session Cutting edge analytics # How many @traffordDataLab followers are bots? # library(tidyverse) ; library(rtweet) ; library(tweetbotornot) # retrieve followers of @OpenGovInt followers <- get_followers("traffordDataLab", n = "all") followers_info <- lookup_users(followers$user_id) %>% select(screen_name, name, followers = followers_count, following = friends_count) # how many followers are bots? bot <- tweetbotornot(followers_info$screen_name[1:50], fast = FALSE) %>% arrange(prob_bot) # arrange by probability estimates bot[order(bot$prob_bot), ] # plot probability estimates bot %>% select(screen_name, prob_bot) %>% arrange(prob_bot) %>% ggplot() + geom_col(aes(x = reorder(screen_name, -prob_bot), y = prob_bot), fill = "#E44690") + scale_y_continuous(limits = c(0, 1), expand = c(0,0)) + coord_flip() + labs(title = "Probability of @traffordDataLab followers being bots", x = NULL, y = NULL) + theme_minimal() + theme(plot.margin=unit(c(1,1,1,1),"cm"), panel.grid.major.y = element_blank(), panel.grid.minor.y = element_blank(), axis.text.y = element_text(hjust = 0)) ggsave("bot_or_not.png", dpi = 300, scale = 1)

Slide 12

Slide 12 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session Graphics

Slide 13

Slide 13 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session Interactive web apps

Slide 14

Slide 14 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session How the Lab uses R

Slide 15

Slide 15 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session Reproducible workflow Open data Programming Version control Sharing

Slide 16

Slide 16 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session An example

Slide 17

Slide 17 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session Scalability

Slide 18

Slide 18 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session Learning R

Slide 19

Slide 19 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session

Slide 20

Slide 20 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session • Reach for R rather than Excel • Follow @hadleywickham, @JennyBryan, @dataandme, @NHSrCommunity and monitor #rstats tweets on Twitter • Find answers or seek help on stackoverflow and RStudio Community • Get a GitHub profile and commit your code • Create a blog using R and post some tutorials • Set up an R User Group with your colleagues Getting started

Slide 21

Slide 21 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session Lab resources GitHub ggplot2 graphics companion tutorials

Slide 22

Slide 22 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session Have a play https://github.com/traffordDataLab/talks/tree/master/2019-03-22_GMPHIN/play

Slide 23

Slide 23 text

2019-03-22, Bolton Council Greater Manchester Public Health Intelligence Session Questions?