This package has been created to provide you convenience functions for working with population health data and is specifically aimed at healthcare providers and services that focus on population health management.
In the next sections we will take you through how you use the tool. This tool will expand over time, as we already have a million ideas of how to adapt and add to the tool.
To load in the PopHealthData attached to the SangerTools package. This is extremely simple, as the data is attached to the package. To load the data into R follow these steps:
<- SangerTools::PopHealthData
health_data glimpse(health_data)
#> Rows: 1,000
#> Columns: 8
#> $ Sex <chr> "Male", "Female", "Male", "Male", "Male", "Female",~
#> $ Smoker <dbl> 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ~
#> $ Diabetes <dbl> 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, ~
#> $ AgeBand <chr> "Children and Young People (0-17)", "Working Age Ad~
#> $ IMD_Decile <dbl> 9, 5, 3, 3, 4, 6, 3, 7, 6, 4, 9, 2, 1, 9, 2, 3, 4, ~
#> $ Ethnicity <chr> "White", "White", "White", "White", "White", "White~
#> $ Locality <chr> "Cheltenham", "Gloucester City", "Cheltenham", "Glo~
#> $ PrimaryCareNetwork <chr> "Cheltenham Central", "Tewkesbury, Newent and Staun~
The data contains:
With the data we can start to work with the function in the package.
The package makes it very simple to create a categorical column chart. This will be implemented in the next example:
# Group by Ethnicity
%>%
health_data ::filter(Diabetes==1) %>%
dplyr::categorical_col_chart(., Ethnicity) SangerTools
# Group by Age Band
%>%
health_data ::filter(Smoker==1) %>%
dplyr::categorical_col_chart(AgeBand) + labs(x="Ethnicity", y="Patient Number") SangerTools
# Group by Sex
%>%
health_data ::filter(Diabetes==1) %>%
dplyr::categorical_col_chart(Sex) + labs(x="Gender") SangerTools
It really is that simple to generate very nice looking proportional charts.
To obtain the crude prevalance rate, this can be achieved below:
<- SangerTools::crude_pr(health_data, health_data %>% dplyr::filter(Diabetes==1), Locality)
crude_prevalence #> Joining, by = "Locality"
# Another way
print(crude_prevalence)
#> # A tibble: 7 x 4
#> Locality demo_pop condition_pop prevalance_1k
#> <chr> <int> <int> <dbl>
#> 1 Cheltenham 249 15 60.2
#> 2 Gloucester City 272 15 55.1
#> 3 South Cotswolds 98 5 51.0
#> 4 The Forest of Dean 81 4 49.4
#> 5 Tewkesbury Newent and Staunton 64 2 31.2
#> 6 Stroud and Berkeley Vale 187 5 26.7
#> 7 North Cotswolds 49 1 20.4
Other functionality added into the package would be to use the multiple CSV reader and clipboard functions.
This essentially copies a data frame to the clipboard for you for then pasting into Excel sheets, or csvs, or raw text.
#health_data %>%
# slice(1:10) %>%
#SangerTools::excel_clip(row.names = FALSE, col.names = TRUE) #Include column names
There is the potential to read from multiple CSVs as well and then these can be fed into data frames.
To implement this function you would need to have a number of CSVs contained in a folder. To read these in, follow the below instructions:
= 'my_file_path_where_csvs_are_stored'
file_path
if (length(SangerTools::multiple_csv_reader(file_path))==0){
message("This won't work without changing the variable input to a local file path with CSVs in")
}#> This won't work without changing the variable input to a local file path with CSVs in
This will need to link to a series of CSV files.
This is an anonymous function and can be called without any arguments
show_brand_palette()
This is also an anonymous function; it will show an extended colour palette
show_extended_palette()
More functions are being added to this tool and a new version of the file will be released on CRAN very soon. Keep an eye out on the associated GitHub for updates, and make sure to pull down the most recent version from CRAN.