Giter VIP home page Giter VIP logo

cqcr's Introduction

cqcr

License: GPL v3 CRAN_Status_Badge GitHub tag R build status AppVeyor build status Codecov test coverage DOI

Get data from the Care Quality Commission API

Access data from the ‘Care Quality Commission’, the health and adult social care regulator for England. The ‘Care Quality Commission’ operates an API, with data available under the Open Government License. Data includes information on service providers, locations such as hospitals, care homes and medical clinics, and ratings and inspection reports.

Installation

The package is available on CRAN, and can be installed with:

install.packages("cqcr")

To install the development version from GitHub use:

#install.packages("devtools")
devtools::install_github("evanodell/cqcr")
library(cqcr)
library(purrr)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(ggplot2)
library(forcats)
loc1 <- cqc_locations_search(care_home = TRUE, 
                             local_authority = c("Waltham Forest",
                                                 "Hackney", "Tower Hamlets"))


care_home_details <- cqc_location_details(loc1)

care_home_df <- map_dfr(care_home_details, `[`,
                        c("location_id", "name", "number_of_beds", 
                          "onspd_longitude", "onspd_latitude"))

care_home_df <- care_home_df %>% 
  mutate(rating = care_home_details %>%
           map(c("current_ratings", "overall", "rating")) %>%
           as.character(),
         rating = recode(rating, "NULL" = "No published rating"),
         rating = factor(rating, levels = c("Outstanding", "Good",
                                            "Requires improvement", 
                                            "Inadequate",
                                            "No published rating")),
         report_date = care_home_details %>%
           map(c("current_ratings", "reportDate")) %>%
           as.character(),
         report_date = ifelse(report_date == "NULL", NA, report_date),
         specialisms = care_home_details %>% map(c("specialisms", "name")))
care_home_df_unnest <- tidyr::unnest(care_home_df, cols = c(specialisms)) %>%
  mutate(specialisms = fct_infreq(specialisms))

theme_set(theme_bw())

ggplot(care_home_df_unnest,
                        aes(x = specialisms, fill = rating)) + 
  geom_bar() + 
  scale_x_discrete(labels = scales::wrap_format(33)) + 
  scale_fill_viridis_d(name="", option = "A", end = 0.95) + 
  labs(x = "Specialism(s)", y = "Number of Care Homes") + 
  theme(legend.position = "bottom",
        axis.text.x = element_text(size = 8, angle = 60, hjust = 1))

Citing cqcr

Odell E (2019). cqcr: Access ‘Care Quality Commission’ Data. doi: 10.5281/zenodo.3452020, R package version 0.1.3.9000, URL: https://github.com/evanodell/cqcr.

A BibTeX entry for LaTeX users is

  @Manual{,
    title = {{cqcr}: Access 'Care Quality Commission' Data},
    author = {Evan Odell},
    doi = {10.5281/zenodo.3452020},
    year = {2019},
    note = {R package version 0.1.3.9000},
    url = {https://github.com/evanodell/cqcr},
  }

Notes

This package is not affiliated with or supported by the Care Quality Commission.

Please note that the ‘cqcr’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

cqcr's People

Contributors

evanodell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

perbinder

cqcr's Issues

cqc_changes : Error in `dplyr::bind_rows()`: ! Argument 1 must be a data frame or a named atomic vector.

Hi

I ran this snippet and got the error in the title. Hope the copy+paste traces below will help.

changes_location <- cqc_changes(organisation_type = c("location"),
start_date = "2000-01-01", end_date = Sys.Date(), verbose = TRUE,
clean_names = TRUE)

I am using cqcr 0.1.3.9000 from github, and R 4.2.3. On Win10.

rlang::last_error()
<error/rlang_error>
Error in dplyr::bind_rows():
! Argument 1 must be a data frame or a named atomic vector.


Backtrace:

  1. cqcr::cqc_changes(...)
  2. cqcr:::cqc_get_data(...)
  3. cqcr:::cqc_multi_page_get_data(...)
  4. dplyr::bind_rows(cont[[type]])

rlang::last_trace()
<error/rlang_error>
Error in dplyr::bind_rows():
! Argument 1 must be a data frame or a named atomic vector.


Backtrace:

  1. └─cqcr::cqc_changes(...)
  2. └─cqcr:::cqc_get_data(...)
  3. └─cqcr:::cqc_multi_page_get_data(...)
    
  4.   └─dplyr::bind_rows(cont[[type]])
    
  5.     └─rlang::abort(glue("Argument {i} must be a data frame or a named atomic vector."))
    

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.