Skip to content

craig-parylo/cvdprevent

Repository files navigation

CVD Prevent cvdprevent website

CRAN status

CVD Prevent is an R package that provides a user-friendly interface to the NHS CVDPREVENT API. This enables analysts, researchers and healthcare professionals to access and work with England-wide primary care cardiovascular disease (CVD) audit data directly from R.

The Cardiovascular Disease Prevention Audit (CVDPREVENT) automatically extracts routinely held GP data. The Data & Improvement Tool provides open access to the data, with clear, actionable insights for those tasked with improving cardiovascular health.


Features

  • Simple R functions to make API requests and retrieve CVD indicator and area data
  • Tidyverse-friendly outputs (mostly tibbles)
  • Support for listing indicators, metrics, time periods, areas and more
  • Helper functions for searching and exploring heirarchical NHS area structures
  • See full API documentation for endpoints and reference

Installation

You can install the latest development version from GitHub with:

# install.packages("pak")
pak::pak("craig-parylo/cvdprevent")

Or install the latest stable release from CRAN:

pak::pak("cvdprevent")

Getting started

library(cvdprevent)

# List all available indicators (first 4 shown)
cvd_indicator_list(time_period_id = 22, system_level_id = 1) |>
  dplyr::select(dplyr::any_of(c(
    "IndicatorID",
    "IndicatorCode",
    "IndicatorShortName"
  ))) |>
  dplyr::slice_head(n = 4)
#> # A tibble: 4 × 3
#>   IndicatorID IndicatorCode IndicatorShortName                                  
#>         <int> <chr>         <chr>                                               
#> 1           1 CVDP001AF     AF: Prevalence (CVDP001AF)                          
#> 2           2 CVDP002HYP    Hypertension: Treated to appropriate threshold (age…
#> 3           3 CVDP003HYP    Hypertension: Treated to appropriate threshold (age…
#> 4           4 CVDP004HYP    Hypertension: BP monitoring (CVDP004HYP)

Typical outputs are tibbles, making them easy to filter and manipulate:

# List the latest four time periods for 'Standard' indicators
cvd_time_period_list() |>
  dplyr::filter(IndicatorTypeName == "Standard") |>
  dplyr::slice_max(order_by = TimePeriodID, n = 4) |>
  dplyr::select(TimePeriodID, TimePeriodName)
#> # A tibble: 4 × 2
#>   TimePeriodID TimePeriodName   
#>          <int> <chr>            
#> 1           26 To June 2025     
#> 2           24 To March 2025    
#> 3           22 To December 2024 
#> 4           20 To September 2024

See the package vignette for more examples and guidance:

vignette("using_cvdprevent", package = "cvdprevent")

Documentation


Dependencies

cvdprevent is designed to work seamlessly with the tidyverse, and depends on:

Install these with:

# install the packages
pak::pak(c(
  "httr2",
  "jsonlite",
  "dplyr",
  "purrr",
  "tidyr",
  "tibble",
  "cli",
  "glue"
))

Contributing

Contributions, suggestions or bug reports are welcome! Please:

  • Submit issues or pull requests via GitHub Issues
  • Follow the function documentation style (see source files)
  • Add examples and tests for new functionality

License

This package is licensed under the MIT License. See LICENSE for details.


Acknowledgements


For more information, see the package website or the API documentation.

Packages

No packages published

Languages