#' Extract demographics data from table returned by prepare_demographics_sc
#'
#' @param demographics_sc_tbl Tibble returned by the
#' prepare_demographics_sc function
#'
#' @return Tibble with only demographics data
#' @export
#'
#' @importFrom magrittr "%>%"
pull_demographics <- function(demographics_sc_tbl) {
stopifnot(all(c(
"patient_id",
"birth_year",
"race",
"ethnicity",
"collection_date"
) %in% colnames(demographics_sc_tbl)))
output_tbl <- demographics_sc_tbl %>%
dplyr::arrange(patient_id, dplyr::desc(collection_date)) %>%
dplyr::select(
"patient_id",
"birth_year",
"race",
"ethnicity"
) %>%
dplyr::filter(!is.na(patient_id)) %>%
dplyr::distinct()
output_tbl <- tidy_up_race(output_tbl)
return(output_tbl)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.