diff --git a/R/table-nih-enrollment.R b/R/table-nih-enrollment.R
index 3d48032..2fdb2aa 100644
--- a/R/table-nih-enrollment.R
+++ b/R/table-nih-enrollment.R
@@ -21,6 +21,7 @@
#' @author Will Beasley, Peter Higgins, Andrew Peters, Sreeharsha Mandem
#'
#' @examples
+#' library(magrittr)
#' ds_1 <- tibble::tribble(
#' ~subject_id, ~gender , ~race , ~ethnicity ,
#' 1L, "Male" , "Black or African American", "Not Hispanic or Latino" ,
@@ -36,7 +37,6 @@
#' table_nih_enrollment(ds_1)
#' table_nih_enrollment_pretty(ds_1)
#'
-#' \dontrun{
#' table_nih_enrollment(ds_1) %>%
#' tidyr::spread(key=gender, value=n)
#'
@@ -46,7 +46,6 @@
#' ) %>%
#' dplyr::select(-gender, -ethnicity) %>%
#' tidyr::spread(key=gender_ethnicity, value=n)
-#' }
#'
#' ds_2 <- tibble::tribble(
#' ~subject_id, ~gender , ~race , ~ethnicity ,
@@ -70,7 +69,6 @@
#' table_nih_enrollment_pretty(ds_2, d_lu_ethnicity=ds_lu_ethnicity)
#'
#' ## Read a 500-patient fake dataset
-#' library(magrittr)
#' path <- system.file("misc/example-data-1.csv", package="codified")
#' ds_3 <- readr::read_csv(path) %>%
#' dplyr::mutate(
@@ -109,15 +107,13 @@
#' d_lu_ethnicity = ds_lu_ethnicity
#' )
#'
-#'
#' table_nih_enrollment_pretty(
#' d = ds_3,
#' d_lu_gender = ds_lu_gender,
#' d_lu_race = ds_lu_race,
#' d_lu_ethnicity = ds_lu_ethnicity
#' )
-#'
-#'
+
#' @export
table_nih_enrollment <- function( d, d_lu_gender=NULL, d_lu_race=NULL, d_lu_ethnicity=NULL ) {
@@ -151,12 +147,7 @@ table_nih_enrollment <- function( d, d_lu_gender=NULL, d_lu_race=NULL, d_lu_ethn
gender = levels_gender,
race = levels_race,
ethnicity = levels_ethnicity
- ) #%>%
- # dplyr::transmute(
- # gender_ethnicity = paste0(.data$gender, " by ", .data$ethnicity)
- # ) %>%
- # dplyr::pull(gender_ethnicity) %>%
- # dput()
+ )
if( !is.null(d_lu_gender) ) {
d <- d %>%
@@ -186,7 +177,7 @@ table_nih_enrollment <- function( d, d_lu_gender=NULL, d_lu_race=NULL, d_lu_ethn
gender = factor(.data$gender , levels=levels_gender ),
race = factor(.data$race , levels=levels_race ),
ethnicity = factor(.data$ethnicity, levels=levels_ethnicity ),
- n = dplyr::coalesce(.data$n, 0L)
+ n = dplyr::coalesce(.data$n, 0L)
) %>%
dplyr::select(.data$gender, .data$race, .data$ethnicity, .data$n) %>%
dplyr::arrange(.data$gender, .data$race, .data$ethnicity)
@@ -212,31 +203,16 @@ table_nih_enrollment_pretty <- function(d, d_lu_gender=NULL, d_lu_race=NULL, d_l
table_nih_enrollment(d, d_lu_gender, d_lu_race, d_lu_ethnicity) %>%
dplyr::mutate(
- # n = scales::comma(n),
- # n = n + 1000, # This line is just to test the commas
gender_ethnicity = paste0(.data$gender, " by ", .data$ethnicity)
) %>%
dplyr::select(-.data$gender, -.data$ethnicity) %>%
tidyr::spread(key=.data$gender_ethnicity, value=.data$n) %>%
dplyr::select(!!column_order) %>%
- # dplyr::select(
- # `Racial\nCategories` = `race`,
- # `Female` = `Female by Not Hispanic or Latino`,
- # `Male` = `Male by Not Hispanic or Latino`,
- # `Unknown/ Not Reported` = `Unknown/Not Reported by Not Hispanic or Latino`,
- # `Female` = `Female by Hispanic or Latino`,
- # `Male` = `Male by Hispanic or Latino`,
- # `Unknown/ Not Reported` = `Unknown/Not Reported by Hispanic or Latino`,
- # `Female` = `Female by Unknown/Not Reported Ethnicity`,
- # `Male` = `Male by Unknown/Not Reported Ethnicity`,
- # `Unknown/ Not Reported` = `Unknown/Not Reported by Unknown/Not Reported Ethnicity`,
- # ) %>%
knitr::kable(
- format = "html",
- # align = "lrrrrrrrrr",
+ format = "html",
format.args = list(big.mark=","),
escape = FALSE,
- col.names = c(
+ col.names = c(
"Racial\nCategories",
"Female",
"Male",
@@ -262,4 +238,3 @@ table_nih_enrollment_pretty <- function(d, d_lu_gender=NULL, d_lu_race=NULL, d_l
)) %>%
kableExtra::add_header_above(c(" " = 1L, "Ethnic Categories" = 9L))
}
-
diff --git a/inst/doc/nih-enrollment-html.R b/inst/doc/nih-enrollment-html.R
index 8016f62..6a0cae0 100644
--- a/inst/doc/nih-enrollment-html.R
+++ b/inst/doc/nih-enrollment-html.R
@@ -32,21 +32,21 @@ ds %>%
knitr::kable(caption = "Observed Dataset (first ten rows)")
ds_lu_gender <- tibble::tribble(
- ~input, ~displayed ,
- "0" , "Female",
- "1" , "Male",
+ ~input, ~displayed ,
+ "0" , "Female" ,
+ "1" , "Male" ,
"U" , "Unknown/Not Reported"
)
knitr::kable(ds_lu_gender, caption = "Gender Mapping")
ds_lu_race <- tibble::tribble(
- ~input , ~displayed ,
- "1" , "American Indian/Alaska Native",
- "2" , "Asian",
- "3" , "Native Hawaiian or Other Pacific Islander",
- "4" , "Black or African American",
- "5" , "White",
- "M" , "More than One Race",
+ ~input , ~displayed ,
+ "1" , "American Indian/Alaska Native" ,
+ "2" , "Asian" ,
+ "3" , "Native Hawaiian or Other Pacific Islander" ,
+ "4" , "Black or African American" ,
+ "5" , "White" ,
+ "M" , "More than One Race" ,
"6" , "Unknown or Not Reported"
)
knitr::kable(ds_lu_race, caption = "Race Mapping")
diff --git a/inst/doc/nih-enrollment-html.Rmd b/inst/doc/nih-enrollment-html.Rmd
index b875294..7470fc9 100644
--- a/inst/doc/nih-enrollment-html.Rmd
+++ b/inst/doc/nih-enrollment-html.Rmd
@@ -65,21 +65,21 @@ ds %>%
knitr::kable(caption = "Observed Dataset (first ten rows)")
ds_lu_gender <- tibble::tribble(
- ~input, ~displayed ,
- "0" , "Female",
- "1" , "Male",
+ ~input, ~displayed ,
+ "0" , "Female" ,
+ "1" , "Male" ,
"U" , "Unknown/Not Reported"
)
knitr::kable(ds_lu_gender, caption = "Gender Mapping")
ds_lu_race <- tibble::tribble(
- ~input , ~displayed ,
- "1" , "American Indian/Alaska Native",
- "2" , "Asian",
- "3" , "Native Hawaiian or Other Pacific Islander",
- "4" , "Black or African American",
- "5" , "White",
- "M" , "More than One Race",
+ ~input , ~displayed ,
+ "1" , "American Indian/Alaska Native" ,
+ "2" , "Asian" ,
+ "3" , "Native Hawaiian or Other Pacific Islander" ,
+ "4" , "Black or African American" ,
+ "5" , "White" ,
+ "M" , "More than One Race" ,
"6" , "Unknown or Not Reported"
)
knitr::kable(ds_lu_race, caption = "Race Mapping")
@@ -122,15 +122,12 @@ codified::table_nih_enrollment_pretty(
REDCap Data Source
=====================================================
-
A hosted (fake) clinical trial dataset demonstrates how to extract demographic data from [REDCap](https://projectredcap.org/) and then present the demographic data in the NIH Inclusion Enrollment Report format.
## Establish Datasets
-
First, install the `REDCapR` package if necessary, and then [load it into memory](http://r-pkgs.had.co.nz/package.html#package).
-
```{r install-redcapr}
if( !requireNamespace("REDCapR", quietly=T) )
devtools::install_github("OuhscBbmc/REDCapR")
diff --git a/inst/doc/nih-enrollment-html.html b/inst/doc/nih-enrollment-html.html
index 9ca3abc..ea71978 100644
--- a/inst/doc/nih-enrollment-html.html
+++ b/inst/doc/nih-enrollment-html.html
@@ -1530,177 +1530,363 @@
Establish Datasets
head(10) %>%
knitr::kable(caption = "Observed Dataset (first ten rows)")
-Observed Dataset (first ten rows)
+
+Observed Dataset (first ten rows)
+
-
+
+record_id
+ |
+
+name_last
+ |
+
+dob
+ |
+
+ethnicity
+ |
+
+race
+ |
+
+gender
+ |
-
-1 |
-Cornel |
-1991-05-13 |
-1 |
-4 |
-0 |
-
-
-2 |
-Wojdyla |
-1931-10-14 |
-1 |
-4 |
-0 |
-
-
-3 |
-Stunkard |
-1964-09-15 |
-1 |
-3 |
-1 |
-
-
-4 |
-Cimochowski |
-1969-05-03 |
-1 |
-4 |
-1 |
-
-
-5 |
-Woodland |
-1969-11-22 |
-1 |
-4 |
-0 |
-
-
-6 |
-Pistoia |
-1943-08-26 |
-1 |
-4 |
-1 |
-
-
-7 |
-Ahlquist |
-1944-01-22 |
-1 |
-4 |
-0 |
-
-
-8 |
-Ashlin |
-1931-04-14 |
-1 |
-4 |
-1 |
-
-
-9 |
-Djokovic |
-1962-07-07 |
-1 |
-1 |
-1 |
-
-
-10 |
-Mosses |
-1978-06-20 |
-1 |
-3 |
-0 |
+
+
+1
+ |
+
+Cornel
+ |
+
+1991-05-13
+ |
+
+1
+ |
+
+4
+ |
+
+0
+ |
+
+
+
+2
+ |
+
+Wojdyla
+ |
+
+1931-10-14
+ |
+
+1
+ |
+
+4
+ |
+
+0
+ |
+
+
+
+3
+ |
+
+Stunkard
+ |
+
+1964-09-15
+ |
+
+1
+ |
+
+3
+ |
+
+1
+ |
+
+
+
+4
+ |
+
+Cimochowski
+ |
+
+1969-05-03
+ |
+
+1
+ |
+
+4
+ |
+
+1
+ |
+
+
+
+5
+ |
+
+Woodland
+ |
+
+1969-11-22
+ |
+
+1
+ |
+
+4
+ |
+
+0
+ |
+
+
+
+6
+ |
+
+Pistoia
+ |
+
+1943-08-26
+ |
+
+1
+ |
+
+4
+ |
+
+1
+ |
+
+
+
+7
+ |
+
+Ahlquist
+ |
+
+1944-01-22
+ |
+
+1
+ |
+
+4
+ |
+
+0
+ |
+
+
+
+8
+ |
+
+Ashlin
+ |
+
+1931-04-14
+ |
+
+1
+ |
+
+4
+ |
+
+1
+ |
+
+
+
+9
+ |
+
+Djokovic
+ |
+
+1962-07-07
+ |
+
+1
+ |
+
+1
+ |
+
+1
+ |
+
+
+
+10
+ |
+
+Mosses
+ |
+
+1978-06-20
+ |
+
+1
+ |
+
+3
+ |
+
+0
+ |
ds_lu_gender <- tibble::tribble(
- ~input, ~displayed ,
- "0" , "Female",
- "1" , "Male",
+ ~input, ~displayed ,
+ "0" , "Female" ,
+ "1" , "Male" ,
"U" , "Unknown/Not Reported"
)
knitr::kable(ds_lu_gender, caption = "Gender Mapping")
-Gender Mapping
+
+Gender Mapping
+
-
+
+input
+ |
+
+displayed
+ |
-
-0 |
-Female |
+
+
+0
+ |
+
+Female
+ |
-
-1 |
-Male |
+
+
+1
+ |
+
+Male
+ |
-
-U |
-Unknown/Not Reported |
+
+
+U
+ |
+
+Unknown/Not Reported
+ |
ds_lu_race <- tibble::tribble(
- ~input , ~displayed ,
- "1" , "American Indian/Alaska Native",
- "2" , "Asian",
- "3" , "Native Hawaiian or Other Pacific Islander",
- "4" , "Black or African American",
- "5" , "White",
- "M" , "More than One Race",
+ ~input , ~displayed ,
+ "1" , "American Indian/Alaska Native" ,
+ "2" , "Asian" ,
+ "3" , "Native Hawaiian or Other Pacific Islander" ,
+ "4" , "Black or African American" ,
+ "5" , "White" ,
+ "M" , "More than One Race" ,
"6" , "Unknown or Not Reported"
)
knitr::kable(ds_lu_race, caption = "Race Mapping")
-Race Mapping
+
+Race Mapping
+
-
+
+input
+ |
+
+displayed
+ |
-
-1 |
-American Indian/Alaska Native |
+
+
+1
+ |
+
+American Indian/Alaska Native
+ |
-
-2 |
-Asian |
+
+
+2
+ |
+
+Asian
+ |
-
-3 |
-Native Hawaiian or Other Pacific Islander |
+
+
+3
+ |
+
+Native Hawaiian or Other Pacific Islander
+ |
-
-4 |
-Black or African American |
+
+
+4
+ |
+
+Black or African American
+ |
-
-5 |
-White |
+
+
+5
+ |
+
+White
+ |
-
-M |
-More than One Race |
+
+
+M
+ |
+
+More than One Race
+ |
-
-6 |
-Unknown or Not Reported |
+
+
+6
+ |
+
+Unknown or Not Reported
+ |
@@ -1712,25 +1898,43 @@ Establish Datasets
)
knitr::kable(ds_lu_ethnicity, caption = "Ethnicity Mapping")
-Ethnicity Mapping
+
+Ethnicity Mapping
+
-
+
+input
+ |
+
+displayed
+ |
-
-2 |
-Not Hispanic or Latino |
+
+
+2
+ |
+
+Not Hispanic or Latino
+ |
-
-1 |
-Hispanic or Latino |
+
+
+1
+ |
+
+Hispanic or Latino
+ |
-
-0 |
-Unknown/Not Reported Ethnicity |
+
+
+0
+ |
+
+Unknown/Not Reported Ethnicity
+ |
@@ -1746,393 +1950,907 @@ Apply Map to Observed Dataset
knitr::kable(ds_summary_long, caption = "Counts of Each Subgroup")
-Counts of Each Subgroup
+
+Counts of Each Subgroup
+
-
+
+gender
+ |
+
+race
+ |
+
+ethnicity
+ |
+
+n
+ |
-
-Female |
-American Indian/Alaska Native |
-Not Hispanic or Latino |
-1 |
-
-
-Female |
-American Indian/Alaska Native |
-Hispanic or Latino |
-8 |
-
-
-Female |
-American Indian/Alaska Native |
-Unknown/Not Reported Ethnicity |
-0 |
-
-
-Female |
-Asian |
-Not Hispanic or Latino |
-0 |
-
-
-Female |
-Asian |
-Hispanic or Latino |
-0 |
-
-
-Female |
-Asian |
-Unknown/Not Reported Ethnicity |
-0 |
-
-
-Female |
-Native Hawaiian or Other Pacific Islander |
-Not Hispanic or Latino |
-1 |
-
-
-Female |
-Native Hawaiian or Other Pacific Islander |
-Hispanic or Latino |
-28 |
-
-
-Female |
-Native Hawaiian or Other Pacific Islander |
-Unknown/Not Reported Ethnicity |
-3 |
-
-
-Female |
-Black or African American |
-Not Hispanic or Latino |
-1 |
-
-
-Female |
-Black or African American |
-Hispanic or Latino |
-172 |
-
-
-Female |
-Black or African American |
-Unknown/Not Reported Ethnicity |
-14 |
-
-
-Female |
-White |
-Not Hispanic or Latino |
-1 |
-
-
-Female |
-White |
-Hispanic or Latino |
-22 |
-
-
-Female |
-White |
-Unknown/Not Reported Ethnicity |
-2 |
-
-
-Female |
-More than One Race |
-Not Hispanic or Latino |
-0 |
-
-
-Female |
-More than One Race |
-Hispanic or Latino |
-0 |
-
-
-Female |
-More than One Race |
-Unknown/Not Reported Ethnicity |
-0 |
-
-
-Female |
-Unknown or Not Reported |
-Not Hispanic or Latino |
-0 |
-
-
-Female |
-Unknown or Not Reported |
-Hispanic or Latino |
-7 |
-
-
-Female |
-Unknown or Not Reported |
-Unknown/Not Reported Ethnicity |
-0 |
-
-
-Male |
-American Indian/Alaska Native |
-Not Hispanic or Latino |
-0 |
-
-
-Male |
-American Indian/Alaska Native |
-Hispanic or Latino |
-10 |
-
-
-Male |
-American Indian/Alaska Native |
-Unknown/Not Reported Ethnicity |
-0 |
-
-
-Male |
-Asian |
-Not Hispanic or Latino |
-0 |
-
-
-Male |
-Asian |
-Hispanic or Latino |
-0 |
-
-
-Male |
-Asian |
-Unknown/Not Reported Ethnicity |
-0 |
-
-
-Male |
-Native Hawaiian or Other Pacific Islander |
-Not Hispanic or Latino |
-1 |
-
-
-Male |
-Native Hawaiian or Other Pacific Islander |
-Hispanic or Latino |
-22 |
-
-
-Male |
-Native Hawaiian or Other Pacific Islander |
-Unknown/Not Reported Ethnicity |
-1 |
-
-
-Male |
-Black or African American |
-Not Hispanic or Latino |
-5 |
-
-
-Male |
-Black or African American |
-Hispanic or Latino |
-154 |
-
-
-Male |
-Black or African American |
-Unknown/Not Reported Ethnicity |
-6 |
-
-
-Male |
-White |
-Not Hispanic or Latino |
-0 |
-
-
-Male |
-White |
-Hispanic or Latino |
-33 |
-
-
-Male |
-White |
-Unknown/Not Reported Ethnicity |
-1 |
-
-
-Male |
-More than One Race |
-Not Hispanic or Latino |
-0 |
-
-
-Male |
-More than One Race |
-Hispanic or Latino |
-0 |
-
-
-Male |
-More than One Race |
-Unknown/Not Reported Ethnicity |
-0 |
-
-
-Male |
-Unknown or Not Reported |
-Not Hispanic or Latino |
-0 |
-
-
-Male |
-Unknown or Not Reported |
-Hispanic or Latino |
-7 |
-
-
-Male |
-Unknown or Not Reported |
-Unknown/Not Reported Ethnicity |
-0 |
-
-
-Unknown/Not Reported |
-American Indian/Alaska Native |
-Not Hispanic or Latino |
-0 |
-
-
-Unknown/Not Reported |
-American Indian/Alaska Native |
-Hispanic or Latino |
-0 |
-
-
-Unknown/Not Reported |
-American Indian/Alaska Native |
-Unknown/Not Reported Ethnicity |
-0 |
-
-
-Unknown/Not Reported |
-Asian |
-Not Hispanic or Latino |
-0 |
-
-
-Unknown/Not Reported |
-Asian |
-Hispanic or Latino |
-0 |
-
-
-Unknown/Not Reported |
-Asian |
-Unknown/Not Reported Ethnicity |
-0 |
-
-
-Unknown/Not Reported |
-Native Hawaiian or Other Pacific Islander |
-Not Hispanic or Latino |
-0 |
-
-
-Unknown/Not Reported |
-Native Hawaiian or Other Pacific Islander |
-Hispanic or Latino |
-0 |
-
-
-Unknown/Not Reported |
-Native Hawaiian or Other Pacific Islander |
-Unknown/Not Reported Ethnicity |
-0 |
-
-
-Unknown/Not Reported |
-Black or African American |
-Not Hispanic or Latino |
-0 |
-
-
-Unknown/Not Reported |
-Black or African American |
-Hispanic or Latino |
-0 |
-
-
-Unknown/Not Reported |
-Black or African American |
-Unknown/Not Reported Ethnicity |
-0 |
-
-
-Unknown/Not Reported |
-White |
-Not Hispanic or Latino |
-0 |
-
-
-Unknown/Not Reported |
-White |
-Hispanic or Latino |
-0 |
-
-
-Unknown/Not Reported |
-White |
-Unknown/Not Reported Ethnicity |
-0 |
-
-
-Unknown/Not Reported |
-More than One Race |
-Not Hispanic or Latino |
-0 |
-
-
-Unknown/Not Reported |
-More than One Race |
-Hispanic or Latino |
-0 |
-
-
-Unknown/Not Reported |
-More than One Race |
-Unknown/Not Reported Ethnicity |
-0 |
-
-
-Unknown/Not Reported |
-Unknown or Not Reported |
-Not Hispanic or Latino |
-0 |
-
-
-Unknown/Not Reported |
-Unknown or Not Reported |
-Hispanic or Latino |
-0 |
-
-
-Unknown/Not Reported |
-Unknown or Not Reported |
-Unknown/Not Reported Ethnicity |
-0 |
+
+
+Female
+ |
+
+American Indian/Alaska Native
+ |
+
+Not Hispanic or Latino
+ |
+
+1
+ |
+
+
+
+Female
+ |
+
+American Indian/Alaska Native
+ |
+
+Hispanic or Latino
+ |
+
+8
+ |
+
+
+
+Female
+ |
+
+American Indian/Alaska Native
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+0
+ |
+
+
+
+Female
+ |
+
+Asian
+ |
+
+Not Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Female
+ |
+
+Asian
+ |
+
+Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Female
+ |
+
+Asian
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+0
+ |
+
+
+
+Female
+ |
+
+Native Hawaiian or Other Pacific Islander
+ |
+
+Not Hispanic or Latino
+ |
+
+1
+ |
+
+
+
+Female
+ |
+
+Native Hawaiian or Other Pacific Islander
+ |
+
+Hispanic or Latino
+ |
+
+28
+ |
+
+
+
+Female
+ |
+
+Native Hawaiian or Other Pacific Islander
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+3
+ |
+
+
+
+Female
+ |
+
+Black or African American
+ |
+
+Not Hispanic or Latino
+ |
+
+1
+ |
+
+
+
+Female
+ |
+
+Black or African American
+ |
+
+Hispanic or Latino
+ |
+
+172
+ |
+
+
+
+Female
+ |
+
+Black or African American
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+14
+ |
+
+
+
+Female
+ |
+
+White
+ |
+
+Not Hispanic or Latino
+ |
+
+1
+ |
+
+
+
+Female
+ |
+
+White
+ |
+
+Hispanic or Latino
+ |
+
+22
+ |
+
+
+
+Female
+ |
+
+White
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+2
+ |
+
+
+
+Female
+ |
+
+More than One Race
+ |
+
+Not Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Female
+ |
+
+More than One Race
+ |
+
+Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Female
+ |
+
+More than One Race
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+0
+ |
+
+
+
+Female
+ |
+
+Unknown or Not Reported
+ |
+
+Not Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Female
+ |
+
+Unknown or Not Reported
+ |
+
+Hispanic or Latino
+ |
+
+7
+ |
+
+
+
+Female
+ |
+
+Unknown or Not Reported
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+0
+ |
+
+
+
+Male
+ |
+
+American Indian/Alaska Native
+ |
+
+Not Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Male
+ |
+
+American Indian/Alaska Native
+ |
+
+Hispanic or Latino
+ |
+
+10
+ |
+
+
+
+Male
+ |
+
+American Indian/Alaska Native
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+0
+ |
+
+
+
+Male
+ |
+
+Asian
+ |
+
+Not Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Male
+ |
+
+Asian
+ |
+
+Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Male
+ |
+
+Asian
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+0
+ |
+
+
+
+Male
+ |
+
+Native Hawaiian or Other Pacific Islander
+ |
+
+Not Hispanic or Latino
+ |
+
+1
+ |
+
+
+
+Male
+ |
+
+Native Hawaiian or Other Pacific Islander
+ |
+
+Hispanic or Latino
+ |
+
+22
+ |
+
+
+
+Male
+ |
+
+Native Hawaiian or Other Pacific Islander
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+1
+ |
+
+
+
+Male
+ |
+
+Black or African American
+ |
+
+Not Hispanic or Latino
+ |
+
+5
+ |
+
+
+
+Male
+ |
+
+Black or African American
+ |
+
+Hispanic or Latino
+ |
+
+154
+ |
+
+
+
+Male
+ |
+
+Black or African American
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+6
+ |
+
+
+
+Male
+ |
+
+White
+ |
+
+Not Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Male
+ |
+
+White
+ |
+
+Hispanic or Latino
+ |
+
+33
+ |
+
+
+
+Male
+ |
+
+White
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+1
+ |
+
+
+
+Male
+ |
+
+More than One Race
+ |
+
+Not Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Male
+ |
+
+More than One Race
+ |
+
+Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Male
+ |
+
+More than One Race
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+0
+ |
+
+
+
+Male
+ |
+
+Unknown or Not Reported
+ |
+
+Not Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Male
+ |
+
+Unknown or Not Reported
+ |
+
+Hispanic or Latino
+ |
+
+7
+ |
+
+
+
+Male
+ |
+
+Unknown or Not Reported
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+American Indian/Alaska Native
+ |
+
+Not Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+American Indian/Alaska Native
+ |
+
+Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+American Indian/Alaska Native
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+Asian
+ |
+
+Not Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+Asian
+ |
+
+Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+Asian
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+Native Hawaiian or Other Pacific Islander
+ |
+
+Not Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+Native Hawaiian or Other Pacific Islander
+ |
+
+Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+Native Hawaiian or Other Pacific Islander
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+Black or African American
+ |
+
+Not Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+Black or African American
+ |
+
+Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+Black or African American
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+White
+ |
+
+Not Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+White
+ |
+
+Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+White
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+More than One Race
+ |
+
+Not Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+More than One Race
+ |
+
+Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+More than One Race
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+Unknown or Not Reported
+ |
+
+Not Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+Unknown or Not Reported
+ |
+
+Hispanic or Latino
+ |
+
+0
+ |
+
+
+
+Unknown/Not Reported
+ |
+
+Unknown or Not Reported
+ |
+
+Unknown/Not Reported Ethnicity
+ |
+
+0
+ |
@@ -2453,7 +3171,7 @@ Establish Datasets
token = "F304DEC3793FECC3B6DEEFF66302CAD3", # User-speciifc token/password.
guess_type = FALSE # Keep all variables as strings/characters.
)$data
-## 500 records and 13 columns were read from REDCap in 3.8 seconds. The http status code was 200.
+## 500 records and 13 columns were read from REDCap in 0.7 seconds. The http status code was 200.
Conform to NIH Cosmetics
diff --git a/man/table_nih_enrollment.Rd b/man/table_nih_enrollment.Rd
index 17b2af6..035d03c 100644
--- a/man/table_nih_enrollment.Rd
+++ b/man/table_nih_enrollment.Rd
@@ -27,6 +27,7 @@ Produce an NIH enrollment table, leveraging metadata to adapt to the observed \l
https://grants.nih.gov/grants/how-to-apply-application-guide/forms-d/general/g.500-phs-inclusion-enrollment-report.htm
}
\examples{
+library(magrittr)
ds_1 <- tibble::tribble(
~subject_id, ~gender , ~race , ~ethnicity ,
1L, "Male" , "Black or African American", "Not Hispanic or Latino" ,
@@ -42,7 +43,6 @@ ds_1 <- tibble::tribble(
table_nih_enrollment(ds_1)
table_nih_enrollment_pretty(ds_1)
-\dontrun{
table_nih_enrollment(ds_1) \%>\%
tidyr::spread(key=gender, value=n)
@@ -52,7 +52,6 @@ table_nih_enrollment(ds_1) \%>\%
) \%>\%
dplyr::select(-gender, -ethnicity) \%>\%
tidyr::spread(key=gender_ethnicity, value=n)
-}
ds_2 <- tibble::tribble(
~subject_id, ~gender , ~race , ~ethnicity ,
@@ -76,7 +75,6 @@ table_nih_enrollment(ds_2, d_lu_ethnicity=ds_lu_ethnicity)
table_nih_enrollment_pretty(ds_2, d_lu_ethnicity=ds_lu_ethnicity)
## Read a 500-patient fake dataset
-library(magrittr)
path <- system.file("misc/example-data-1.csv", package="codified")
ds_3 <- readr::read_csv(path) \%>\%
dplyr::mutate(
@@ -115,15 +113,12 @@ table_nih_enrollment(
d_lu_ethnicity = ds_lu_ethnicity
)
-
table_nih_enrollment_pretty(
d = ds_3,
d_lu_gender = ds_lu_gender,
d_lu_race = ds_lu_race,
d_lu_ethnicity = ds_lu_ethnicity
)
-
-
}
\author{
Will Beasley, Peter Higgins, Andrew Peters, Sreeharsha Mandem
diff --git a/vignettes/nih-enrollment-html.Rmd b/vignettes/nih-enrollment-html.Rmd
index b875294..7470fc9 100644
--- a/vignettes/nih-enrollment-html.Rmd
+++ b/vignettes/nih-enrollment-html.Rmd
@@ -65,21 +65,21 @@ ds %>%
knitr::kable(caption = "Observed Dataset (first ten rows)")
ds_lu_gender <- tibble::tribble(
- ~input, ~displayed ,
- "0" , "Female",
- "1" , "Male",
+ ~input, ~displayed ,
+ "0" , "Female" ,
+ "1" , "Male" ,
"U" , "Unknown/Not Reported"
)
knitr::kable(ds_lu_gender, caption = "Gender Mapping")
ds_lu_race <- tibble::tribble(
- ~input , ~displayed ,
- "1" , "American Indian/Alaska Native",
- "2" , "Asian",
- "3" , "Native Hawaiian or Other Pacific Islander",
- "4" , "Black or African American",
- "5" , "White",
- "M" , "More than One Race",
+ ~input , ~displayed ,
+ "1" , "American Indian/Alaska Native" ,
+ "2" , "Asian" ,
+ "3" , "Native Hawaiian or Other Pacific Islander" ,
+ "4" , "Black or African American" ,
+ "5" , "White" ,
+ "M" , "More than One Race" ,
"6" , "Unknown or Not Reported"
)
knitr::kable(ds_lu_race, caption = "Race Mapping")
@@ -122,15 +122,12 @@ codified::table_nih_enrollment_pretty(
REDCap Data Source
=====================================================
-
A hosted (fake) clinical trial dataset demonstrates how to extract demographic data from [REDCap](https://projectredcap.org/) and then present the demographic data in the NIH Inclusion Enrollment Report format.
## Establish Datasets
-
First, install the `REDCapR` package if necessary, and then [load it into memory](http://r-pkgs.had.co.nz/package.html#package).
-
```{r install-redcapr}
if( !requireNamespace("REDCapR", quietly=T) )
devtools::install_github("OuhscBbmc/REDCapR")