library(shinycssloaders)
Registered S3 methods overwritten by 'htmltools':
  method               from         
  print.html           tools:rstudio
  print.shiny.tag      tools:rstudio
  print.shiny.tag.list tools:rstudio
#install.packages("fingertipsR", repos = "https://dev.ropensci.org")
library(fingertipsR)
Registered S3 method overwritten by 'htmlwidgets':
  method           from         
  print.htmlwidget tools:rstudio
library(tidyverse)
Registered S3 methods overwritten by 'dbplyr':
  method         from
  print.tbl_lazy     
  print.tbl_sql      
-- Attaching packages --------------------- tidyverse 1.3.1 --
v ggplot2 3.3.5     v purrr   0.3.4
v tibble  3.1.2     v dplyr   1.0.7
v tidyr   1.1.3     v stringr 1.4.0
v readr   1.4.0     v forcats 0.5.1
-- Conflicts ------------------------ tidyverse_conflicts() --
x dplyr::filter() masks stats::filter()
x dplyr::lag()    masks stats::lag()

Useful info here: https://rstudio-pubs-static.s3.amazonaws.com/274982_54e369ab8e5c4702a99acb15c37cae88.html

local_health_profiles <- profiles(ProfileName = "Local Health")
local_health_profiles$DomainID
[1] 1938133180 1938133183 1938133184 1938133185
all_local_dat <- fingertips_data(
  DomainID = local_health_profiles$DomainID,
  AreaTypeID = "All"
)

  |                                                          
  |                                                    |   0%
  |                                                          
  |                                                    |   1%
  |                                                          
  |=                                                   |   1%
  |                                                          
  |=                                                   |   2%
  |                                                          
  |=                                                   |   3%
  |                                                          
  |==                                                  |   3%
  |                                                          
  |==                                                  |   4%
  |                                                          
  |==                                                  |   5%
  |                                                          
  |===                                                 |   5%
  |                                                          
  |===                                                 |   6%
  |                                                          
  |===                                                 |   7%
  |                                                          
  |====                                                |   7%
  |                                                          
  |====                                                |   8%
  |                                                          
  |=====                                               |   9%
  |                                                          
  |=====                                               |  10%
  |                                                          
  |======                                              |  11%
  |                                                          
  |======                                              |  12%
  |                                                          
  |=======                                             |  13%
  |                                                          
  |=======                                             |  14%
  |                                                          
  |========                                            |  15%
  |                                                          
  |========                                            |  16%
  |                                                          
  |=========                                           |  17%
  |                                                          
  |=========                                           |  18%
  |                                                          
  |==========                                          |  18%
  |                                                          
  |==========                                          |  19%
  |                                                          
  |==========                                          |  20%
  |                                                          
  |===========                                         |  20%
  |                                                          
  |===========                                         |  21%
  |                                                          
  |===========                                         |  22%
  |                                                          
  |============                                        |  22%
  |                                                          
  |============                                        |  23%
  |                                                          
  |============                                        |  24%
  |                                                          
  |=============                                       |  24%
  |                                                          
  |=============                                       |  25%
  |                                                          
  |=============                                       |  26%
  |                                                          
  |==============                                      |  26%
  |                                                          
  |==============                                      |  27%
  |                                                          
  |==============                                      |  28%
  |                                                          
  |===============                                     |  28%
  |                                                          
  |===============                                     |  29%
  |                                                          
  |===============                                     |  30%
  |                                                          
  |================                                    |  30%
  |                                                          
  |================                                    |  31%
  |                                                          
  |=================                                   |  32%
  |                                                          
  |=================                                   |  33%
  |                                                          
  |=================                                   |  34%
  |                                                          
  |==================                                  |  34%
  |                                                          
  |==================                                  |  35%
  |                                                          
  |===================                                 |  36%
  |                                                          
  |===================                                 |  37%
  |                                                          
  |====================                                |  38%
  |                                                          
  |====================                                |  39%
  |                                                          
  |=====================                               |  39%
  |                                                          
  |=====================                               |  40%
  |                                                          
  |=====================                               |  41%
  |                                                          
  |======================                              |  42%
  |                                                          
  |======================                              |  43%
  |                                                          
  |=======================                             |  44%
  |                                                          
  |=======================                             |  45%
  |                                                          
  |========================                            |  45%
  |                                                          
  |========================                            |  46%
  |                                                          
  |========================                            |  47%
  |                                                          
  |=========================                           |  47%
  |                                                          
  |=========================                           |  48%
  |                                                          
  |=========================                           |  49%
  |                                                          
  |==========================                          |  49%
  |                                                          
  |==========================                          |  50%
  |                                                          
  |==========================                          |  51%
  |                                                          
  |===========================                         |  51%
  |                                                          
  |===========================                         |  52%
  |                                                          
  |===========================                         |  53%
  |                                                          
  |============================                        |  53%
  |                                                          
  |============================                        |  54%
  |                                                          
  |============================                        |  55%
  |                                                          
  |=============================                       |  55%
  |                                                          
  |=============================                       |  56%
  |                                                          
  |==============================                      |  57%
  |                                                          
  |==============================                      |  58%
  |                                                          
  |===============================                     |  59%
  |                                                          
  |===============================                     |  60%
  |                                                          
  |===============================                     |  61%
  |                                                          
  |================================                    |  61%
  |                                                          
  |================================                    |  62%
  |                                                          
  |=================================                   |  63%
  |                                                          
  |=================================                   |  64%
  |                                                          
  |==================================                  |  65%
  |                                                          
  |==================================                  |  66%
  |                                                          
  |===================================                 |  66%
  |                                                          
  |===================================                 |  67%
  |                                                          
  |===================================                 |  68%
  |                                                          
  |====================================                |  69%
  |                                                          
  |====================================                |  70%
  |                                                          
  |=====================================               |  70%
  |                                                          
  |=====================================               |  71%
  |                                                          
  |=====================================               |  72%
  |                                                          
  |======================================              |  72%
  |                                                          
  |======================================              |  73%
  |                                                          
  |======================================              |  74%
  |                                                          
  |=======================================             |  74%
  |                                                          
  |=======================================             |  75%
  |                                                          
  |=======================================             |  76%
  |                                                          
  |========================================            |  76%
  |                                                          
  |========================================            |  77%
  |                                                          
  |========================================            |  78%
  |                                                          
  |=========================================           |  78%
  |                                                          
  |=========================================           |  79%
  |                                                          
  |=========================================           |  80%
  |                                                          
  |==========================================          |  80%
  |                                                          
  |==========================================          |  81%
  |                                                          
  |==========================================          |  82%
  |                                                          
  |===========================================         |  82%
  |                                                          
  |===========================================         |  83%
  |                                                          
  |============================================        |  84%
  |                                                          
  |============================================        |  85%
  |                                                          
  |=============================================       |  86%
  |                                                          
  |=============================================       |  87%
  |                                                          
  |==============================================      |  88%
  |                                                          
  |==============================================      |  89%
  |                                                          
  |===============================================     |  90%
  |                                                          
  |===============================================     |  91%
  |                                                          
  |================================================    |  92%
  |                                                          
  |================================================    |  93%
  |                                                          
  |=================================================   |  93%
  |                                                          
  |=================================================   |  94%
  |                                                          
  |=================================================   |  95%
  |                                                          
  |==================================================  |  95%
  |                                                          
  |==================================================  |  96%
  |                                                          
  |==================================================  |  97%
  |                                                          
  |=================================================== |  97%
  |                                                          
  |=================================================== |  98%
  |                                                          
  |=================================================== |  99%
  |                                                          
  |====================================================|  99%
  |                                                          
  |====================================================| 100%
str(all_local_dat)
'data.frame':   854439 obs. of  26 variables:
 $ IndicatorID                        : int  93116 93116 93116 93116 93116 93116 93116 93116 93116 93116 ...
 $ IndicatorName                      : chr  "A&E attendances aged under 5 years old, crude rate" "A&E attendances aged under 5 years old, crude rate" "A&E attendances aged under 5 years old, crude rate" "A&E attendances aged under 5 years old, crude rate" ...
 $ ParentCode                         : chr  NA "E92000001" "E92000001" "E92000001" ...
 $ ParentName                         : chr  NA "England" "England" "England" ...
 $ AreaCode                           : chr  "E92000001" "E06000001" "E06000002" "E06000003" ...
 $ AreaName                           : chr  "England" "Hartlepool" "Middlesbrough" "Redcar and Cleveland" ...
 $ AreaType                           : chr  "England" "County & UA" "County & UA" "County & UA" ...
 $ Sex                                : chr  "Persons" "Persons" "Persons" "Persons" ...
 $ Age                                : chr  "0-4 yrs" "0-4 yrs" "0-4 yrs" "0-4 yrs" ...
 $ CategoryType                       : chr  NA NA NA NA ...
 $ Category                           : chr  NA NA NA NA ...
 $ Timeperiod                         : chr  "2017/18 - 19/20" "2017/18 - 19/20" "2017/18 - 19/20" "2017/18 - 19/20" ...
 $ Value                              : num  643 1695 468 417 1146 ...
 $ LowerCI95.0limit                   : num  642 1674 460 408 1134 ...
 $ UpperCI95.0limit                   : num  643 1715 476 426 1157 ...
 $ LowerCI99.8limit                   : num  642 1663 456 404 1128 ...
 $ UpperCI99.8limit                   : num  643 1727 480 431 1163 ...
 $ Count                              : num  6445297 26995 13595 9175 40125 ...
 $ Denominator                        : num  10031289 15929 29061 22008 35024 ...
 $ Valuenote                          : chr  NA NA NA NA ...
 $ RecentTrend                        : chr  "Cannot be calculated" "Cannot be calculated" "Cannot be calculated" "Cannot be calculated" ...
 $ ComparedtoEnglandvalueorpercentiles: chr  "Not compared" "Worse" "Better" "Better" ...
 $ ComparedtoParentvalueorpercentiles : chr  "Not compared" "Not compared" "Not compared" "Not compared" ...
 $ TimeperiodSortable                 : int  20170000 20170000 20170000 20170000 20170000 20170000 20170000 20170000 20170000 20170000 ...
 $ Newdata                            : chr  NA NA NA NA ...
 $ Comparedtogoal                     : chr  NA NA NA NA ...
all_ward_dat <- all_local_dat %>%
  filter(AreaType == "Ward")
nrow(all_ward_dat)
[1] 432060
all_profiles$DomainID
  [1] 1938132885 1938132886 1938132900 1938132887 1938132888
  [6] 1938132889 1938132890    1000049    1000041    1000042
 [11]    1000043    1000044 1938132983    2000005 1938132829
 [16] 1938133086    3000008    3000007    3000009    3000010
 [21]    2000002    2000003    2000009    2000006 1938132970
 [26]    2000004    1200006 1938132696 1938132695 1938132694
 [31]    8000073 1938133217    3007000 1938133216 1938132701
 [36] 1938132974    8000003    8000005    8000008    8000009
 [41] 1938133345 1938133300    1000002 1938133209 1938132804
 [46] 1938133210 1938133211 1938133212 1938133214 1938132818
 [51]    8000011    8000022 1938133288 1938133368 1938133219
 [56]    8000017 1938133099 1938132720    8000041    8000026
 [61]    8000042    8000043 1938132954 1938132955 1938133302
 [66] 1938132719    8000027    8000030    8000031    8000039
 [71] 1938133369    8000057    8000035 1938133286    8000059
 [76]    8000036    8000037    8000058    8000038    8000060
 [81]    8000063 1938132702 1938132703 1938132704 1938132705
 [86] 1938132726 1938132768 1938132770 1938132767 1938133186
 [91] 1938133152 1938133151 1938133218 1938132773 1938133148
 [96] 1938133149 1938133150 1938132935 1938132790 1938132791
[101] 1938132792 1938132936 1938133084 1938133052 1938132811
[106] 1938132859 1938132891 1938132897 1938132893 1938132894
[111] 1938132814 1938132984 1938132832 1938132833 1938132982
[116] 1938132848 1938132835 1938132895 1938133118 1938132828
[121] 1938132831 1938132834 1938133365 1938132830 1938133085
[126] 1938132883 1938132902 1938132882 1938132901 1938133060
[131] 1938133338 1938132951 1938132916 1938132922 1938132920
[136] 1938132921 1938132923 1938132924 1938132899 1938133001
[141] 1938133004 1938133359 1938133360 1938133361 1938133363
[146] 1938133364 1938133070 1938132908 1938132909 1938132910
[151] 1938132917 1938132929 1938132967 1938132968 1938132960
[156] 1938132915 1938132957 1938132975 1938133101 1938133228
[161] 1938133222 1938133223 1938133257 1938133224 1938133258
[166] 1938133259 1938133260 1938133225 1938133261 1938133226
[171] 1938133229 1938133230 1938133231 1938133232 1938133263
[176] 1938133236 1938133237 1938133238 1938132962 1938133121
[181] 1938132963 1938132964 1938132965 1938132966 1938132973
[186] 1938132980 1938132981 1938133009 1938133056 1938133058
[191] 1938133043 1938133042 1938133044 1938133045 1938133073
[196] 1938133071 1938133119 1938133080 1938133262 1938133081
[201] 1938133090 1938133089 1938133095 1938133096 1938133094
[206] 1938133106 1938133107 1938133108 1938133109 1938133110
[211] 1938133128 1938133138 1938133136 1938133158 1938133135
[216] 1938133137 1938133181 1938133162 1938133145 1938133161
[221] 1938133163 1938133155 1938133144 1938133159 1938133160
[226] 1938133221 1938133143 1938133156 1938133197 1938133154
[231] 1938133142 1938133198 1938133157 1938133220 1938133180
[236] 1938133183 1938133184 1938133185 1938133280 1938133250
[241] 1938133251 1938133252 1938133253 1938133264 1938133265
[246] 1938133266 1938132706 1938133282 1938133283 1938133284
[251] 1938133285 1938133299 1938133293 1938133294 1938133301
[256] 1938133344
all_ward_dat <- fingertips_data(
  DomainID = all_profiles$DomainID,
  AreaTypeID = "8"
) %>%
  filter(AreaType == "Ward")
all_ward_dat %>%
  group_by(IndicatorName, Timeperiod) %>%
  summarise(n = n(), valid = 100 * sum(!is.na(Value)) / n) %>%
  View()
`summarise()` has grouped output by 'IndicatorName'. You can override using the `.groups` argument.
all_ward_dat <- fingertips_data(
  DomainID = all_profiles$DomainID,
  AreaTypeID = "8"
) %>%
  filter(AreaType == "Ward")
LS0tDQp0aXRsZTogIkZpbmdlcnRpcHMgZXhwbG9yYXRpb25zIg0KYXV0aG9yOiBBbmRpIEZ1Z2FyZA0Kb3V0cHV0OiBodG1sX25vdGVib29rDQotLS0NCg0KYGBge3J9DQpsaWJyYXJ5KHNoaW55Y3NzbG9hZGVycykNCiNpbnN0YWxsLnBhY2thZ2VzKCJmaW5nZXJ0aXBzUiIsIHJlcG9zID0gImh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