Open fergustaylor opened 7 years ago
Oddly enough adding a date to the CCG_boundaries_or_location() will return a result. But since it has 207 entries I assume it's just the same result it returns without a date.
ccggeom2 <- st_read("https://openprescribing.net/api/1.0/org_location/?org_type=ccg&date=2012-07-01") %>%
dplyr::rename(row_name = name) %>%
select(-ons_code, -org_type)
unique(filter(dataframe, date=="2012-07-01")$row_name)
oldccgdifferences <- function(argument)
{
dplyr::setdiff(unique(filter(dataframe, date==argument)$row_name), unique(ccggeom$row_name))
}
oldccglist <- lapply(unique(dataframe$date), oldccgdifferences) %>%
setNames(unique(dataframe$date))
Shows the additional CCGs from previous months.
newccgdifferences <- function(argument)
{
dplyr::setdiff(unique(ccggeom$row_name), unique(filter(dataframe, date==argument)$row_name))
}
newccglist <- lapply(unique(dataframe$date), newccgdifferences) %>%
setNames(unique(dataframe$date))
Shows that there are no CCGs listed in ccggeom that aren't listed in previous months. I.e no new CCGs have been formed ccggeom, only disbanded. N.B this only refers to them by name, it doesn't tell you anything about the geometries, which may have changed (i.e absorbed the geography of a now-disbanded ccg, but kept the same title as before).
It's possible to return CCG geometries with st_read, as a simple features collection version of CCG_boundaries_or_location(). Then you can join this to a spending function to give a dataset with the ccg geometries as a column which makes it easier to plot gifs, leaflets, geom_sf stuff over time. BUT this assumes the CCGs are consistent over time, which doesn't appear to be the case going by row_name alone, we know there are name changes, but not necessarily if the geometries change.
Example dataset
But looking at the unique rownames from a spending function. shows some names not included in CCG_boundaries_or_location().
[1] "NHS NEWCASTLE WEST CCG" "NHS NORTH MANCHESTER CCG"
[3] "NHS SOUTH MANCHESTER CCG" "NHS NEWCASTLE NORTH AND EAST CCG" [5] "NHS GATESHEAD CCG" "NHS CENTRAL MANCHESTER CCG"