-
Notifications
You must be signed in to change notification settings - Fork 417
Add new datasets for R4DS #1333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7cb68e3
Add who2 dataset
hadley 954ea38
Add family dataset
hadley bfd2d58
Use use_data()
hadley 78cf48d
Suppress now broken unnest_auto() example
hadley 8fdc3c6
Re-update rda/delete ol .rdata
hadley d03dd8d
Add CMS datasets to demonstrate pivot_wider()
hadley ecc929d
Apply suggestions from code review
hadley e61a18c
Make family an integer
hadley ea51f03
Re-document
hadley 008cb38
Rename to household
hadley 3def24a
Add to index
hadley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
library(tidyverse) | ||
|
||
# Doctors and Clinicians Quality Payment Program PY 2020 Group Public Reporting: | ||
# Patient Experience | ||
|
||
# https://data.cms.gov/provider-data/dataset/8c70-d353 | ||
url <- "https://data.cms.gov/provider-data/api/1/datastore/query/8c70-d353/0?offset=0&count=true&results=true&schema=true&keys=true&format=json&rowIds=false" | ||
|
||
json <- jsonlite::read_json(url) | ||
cms_patient_experience <- json$results |> | ||
map_df(as_tibble) |> | ||
select(org_pac_id, org_nm, measure_cd, measure_title, prf_rate) |> | ||
arrange(org_pac_id, stringi::stri_rank(measure_cd, list(numeric = TRUE))) |> | ||
mutate(prf_rate = as.numeric(prf_rate)) | ||
|
||
write_csv(cms_patient_experience, "data-raw/cms_patient_experience.csv") | ||
usethis::use_data(cms_patient_experience, overwrite = TRUE) | ||
|
||
|
||
# ------------------------------------------------------------------------- | ||
|
||
# Hospice - Provider Data | ||
# A list of hospice agencies with data on the quality of patient care measures. | ||
# https://data.cms.gov/provider-data/dataset/252m-zfp9 | ||
|
||
# Recommended by | ||
# https://twitter.com/hunter_boost/status/1500212341463339008 | ||
|
||
url <- "https://data.cms.gov/provider-data/api/1/datastore/query/252m-zfp9/0?limit=500&offset=0&count=true&results=true&schema=true&keys=true&format=json&rowIds=false" | ||
json <- jsonlite::read_json(url) | ||
|
||
abbr <- tribble( | ||
~measure_name , ~measure_abbr, | ||
"Hospice and Palliative Care Treatment Preferences" , "treat_pref", | ||
"Beliefs & Values Addressed (if desired by the patient)" , "beliefs_addressed", | ||
"Hospice and Palliative Care Pain Screening" , "pain_screening", | ||
"Hospice and Palliative Care Pain Assessment" , "pain_assessment", | ||
"Hospice and Palliative Care Dyspnea Screening" , "dyspnea_screening", | ||
"Hospice and Palliative Care Dyspnea Treatment" , "dyspena_treatment", | ||
"Patient Treated with an Opioid Who Are Given a Bowel Regimen", "opioid_bowel", | ||
"Hospice and Palliative Care Composite Process Measure" , "composite_process", | ||
"Hospice Visits When Death Is Imminent, Measure 1" , "visits_imminent", | ||
) | ||
|
||
cms_patient_care <- json$results |> | ||
map_df(as_tibble) |> | ||
select(ccn = cms_certification_number_ccn, facility_name, measure_name, measure_code, score) |> | ||
mutate(measure_name = na_if(measure_name, "")) |> | ||
fill(measure_name, .direction = "up") |> | ||
filter(str_detect(measure_code, "^H")) |> | ||
mutate(score = as.numeric(na_if(score, "Not Available"))) |> | ||
mutate( | ||
type = str_to_lower(str_remove(measure_code, "H_\\d{3}_\\d{2}_")), | ||
measure_code = NULL | ||
) |> | ||
left_join(abbr, by = "measure_name") |> | ||
select(ccn, facility_name, measure_abbr, score, type) |> | ||
arrange(ccn, measure_abbr, type) | ||
|
||
write_csv(cms_patient_care, "data-raw/cms_patient_care.csv") | ||
usethis::use_data(cms_patient_care, overwrite = TRUE) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.