From b5987715f8a14de067a2669813c08601182cb567 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 6 Sep 2018 21:51:11 -0500 Subject: [PATCH 1/4] accommodate earlier versions of REDCapR; bump version --- DESCRIPTION | 8 +- NEWS.md | 7 +- README.md | 2 +- docs/CODE_OF_CONDUCT.html | 2 +- docs/LICENSE-text.html | 2 +- docs/articles/index.html | 2 +- docs/articles/nih-enrollment-html.html | 221 +-- docs/authors.html | 2 +- docs/index.html | 25 +- docs/news/index.html | 12 +- docs/reference/codified-package.html | 3 +- docs/reference/index.html | 2 +- docs/reference/table_nih_enrollment.html | 12 +- documentation-for-developers/refresh.R | 5 + inst/doc/nih-enrollment-html.R | 19 +- inst/doc/nih-enrollment-html.Rmd | 20 +- inst/doc/nih-enrollment-html.html | 1823 +++++++--------------- man/codified-package.Rd | 1 + vignettes/nih-enrollment-html.Rmd | 20 +- 19 files changed, 798 insertions(+), 1390 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0b7402c..72b9bd8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,8 +2,8 @@ Package: codified Title: Produce standard/formalized demographics tables Description: Augment clinical data with metadata to create output used in conventional publications and reports. -Version: 0.1.1.9001 -Date: 2018-08-27 +Version: 0.2.0 +Date: 2018-09-06 Authors@R: c(person("Will", "Beasley", role = c("aut", "cre"), email = "wibeasley@hotmail.com", comment = c(ORCID = "0000-0002-5613-5006")), person("Peter", "Higgins", role = "ctb")) @@ -16,7 +16,7 @@ Imports: dplyr (>= 0.7.0), magrittr, methods, - readr (>= 1.2.0), + readr (>= 1.1.0), rlang, tibble (>= 1.4.0), tidyr (>= 0.7.0) @@ -29,8 +29,6 @@ Suggests: rmarkdown, sessioninfo, testthat (>= 0.9) -Remotes: - github::tidyverse/readr License: MIT + file LICENSE LazyData: TRUE VignetteBuilder: knitr diff --git a/NEWS.md b/NEWS.md index 9343073..81dda9a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ -# codified 0.0.1.9001 -* Added a `NEWS.md` file to track changes to the package. +# codified 0.2.0 + +* added `table_nih_enrollment()` and `table_nih_enrollment_pretty()`. #2 +* added `nih-enrollment-html` vignette. #6 +* started pkgdown site. #7 diff --git a/README.md b/README.md index 29c807a..814b40f 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ devtools::install_github(repo="OuhscBbmc/codified") In the future, the *release* version can be installed from [CRAN](https://cran.r-project.org/package=codified). ```r -# install.packages("codified") # Not yet on CRAN. +install.packages("codified") ``` The package can be uninstalled from your local machine with `remove.packages("codified")`. diff --git a/docs/CODE_OF_CONDUCT.html b/docs/CODE_OF_CONDUCT.html index 65d0ab4..5d76344 100644 --- a/docs/CODE_OF_CONDUCT.html +++ b/docs/CODE_OF_CONDUCT.html @@ -58,7 +58,7 @@ codified - 0.0.1.9001 + 0.2.0 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 1a22e72..3e01e6f 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -58,7 +58,7 @@ codified - 0.0.1.9001 + 0.2.0 diff --git a/docs/articles/index.html b/docs/articles/index.html index 61abb3f..10a3330 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -58,7 +58,7 @@ codified - 0.0.1.9001 + 0.2.0 diff --git a/docs/articles/nih-enrollment-html.html b/docs/articles/nih-enrollment-html.html index e47f60f..c05c5d9 100644 --- a/docs/articles/nih-enrollment-html.html +++ b/docs/articles/nih-enrollment-html.html @@ -29,7 +29,7 @@ codified - 0.0.1.9001 + 0.2.0 @@ -122,10 +122,45 @@

gender = as.character(gender), race = as.character(race), ethnicity = as.character(ethnicity) - ) -ds %>% - head(10) %>% - knitr::kable(caption = "Observed Dataset (first ten rows)") + ) +
## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
ds %>% 
+  head(10) %>% 
+  knitr::kable(caption = "Observed Dataset (first ten rows)")
@@ -219,13 +254,13 @@

Observed Dataset (first ten rows)
- + @@ -247,17 +282,17 @@

Gender Mapping
- + @@ -295,13 +330,13 @@

Race Mapping
- + @@ -327,14 +362,14 @@

Ethnicity Mapping
@@ -728,12 +763,12 @@

Counts of Each Subgroup
@@ -1034,28 +1069,36 @@

Establish Datasets

First, install the REDCapR package if necessary, and then load it into memory.

- +

Next, download the data from the REDCap database into the ds_2 data.frame.

- -
## 500 records and 13 columns were read from REDCap in 1.7 seconds.  The http status code was 200.
+ +
## 500 records and 13 columns were read from REDCap in 0.6 seconds.  The http status code was 200.

Conform to NIH Cosmetics

Now, convert these demographic data into a properly formatted NIH enrollment table. Pass the ds_lu_gender, ds_lu_race, and ds_lu_ethnicity metadata, which was defined above. As a reminder, these translate values like 1 to Male and 3 to Native Hawaiian or Other Pacific Islander.

- +
@@ -1352,35 +1395,35 @@

Collapsing Levels

Many observed datasets may collect race with a different set of levels. For instance in ds_3, the American Indian level is separate from the Alaska Native level. In the first and second rows in the metadata below, the two levels are effectively combined into theAmerican Indian/Alaska Native level, so it complies with the format of the NIH Enrollment table.

- +
diff --git a/docs/authors.html b/docs/authors.html index eaae250..feb579c 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -58,7 +58,7 @@ codified - 0.0.1.9001 + 0.2.0 diff --git a/docs/index.html b/docs/index.html index 741e450..c02cf7f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -30,7 +30,7 @@ codified - 0.0.1.9001 + 0.2.0 @@ -84,15 +84,16 @@ codified

Produce standard/formalized demographics tables

Clinical researchers often need to document and report the demographics of all consented subjects. A common use case is for reporting to funding agencies, including the National Institutes of Health (NIH). The NIH requires a particular format for the PHS Inclusion Enrollment Report in each annual Research Performance Progress Report (RPPR).

-

The codified package, in combination with the REDCapR package, provides a pipeline to directly extract the demographics of consented subjects from a REDCap database, and to rapidly and reproducibly produce standard demographics tables.

+

The codified package, in combination with the REDCapR package, provides a pipeline to directly extract the demographics of consented subjects from a REDCap database, and to rapidly and reproducibly produce standard demographics tables. This pipeline is demonstrated in the vignette, NIH Enrollment Tables in HTML.

Installation and Documentation

-

In the future, the release version can be installed from CRAN.

-

The development version can be installed from GitHub after installing the devtools package.

- + +

In the future, the release version can be installed from CRAN.

+ +

The package can be uninstalled from your local machine with remove.packages("codified").

@@ -130,16 +131,22 @@

- + + - + + + + + +
Key Value
License License: MIT
Development DocRdoc
+--> diff --git a/docs/news/index.html b/docs/news/index.html index a384371..4c1e79f 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -58,7 +58,7 @@ codified - 0.0.1.9001 + 0.2.0 @@ -113,11 +113,13 @@

Changelog

Source: NEWS.md -
+

-codified 0.0.1.9001

+codified 0.2.0
@@ -126,7 +128,7 @@

Contents

diff --git a/docs/reference/codified-package.html b/docs/reference/codified-package.html index 1bdfd6d..ec346a1 100644 --- a/docs/reference/codified-package.html +++ b/docs/reference/codified-package.html @@ -62,7 +62,7 @@ codified - 0.0.1.9001 + 0.2.0 @@ -129,6 +129,7 @@

codified: Produce standard/formalized demographics tables

See also

Useful links:

diff --git a/docs/reference/table_nih_enrollment.html b/docs/reference/table_nih_enrollment.html index c1e9f8c..113c0b7 100644 --- a/docs/reference/table_nih_enrollment.html +++ b/docs/reference/table_nih_enrollment.html @@ -61,7 +61,7 @@ codified - 0.0.1.9001 + 0.2.0 @@ -472,17 +472,17 @@

Examp ethnicity = as.character(ethnicity) )
#> Parsed with column specification: #> cols( -#> record_id = col_double(), +#> record_id = col_integer(), #> name_last = col_character(), #> name_first = col_character(), #> address = col_character(), #> phone = col_double(), #> dob = col_date(format = ""), -#> ethnicity = col_double(), -#> race = col_double(), -#> gender = col_double(), +#> ethnicity = col_integer(), +#> race = col_integer(), +#> gender = col_integer(), #> height_cm = col_double(), -#> weight_kg = col_double(), +#> weight_kg = col_integer(), #> email = col_character() #> )
ds_lu_gender <- tibble::tribble( diff --git a/documentation-for-developers/refresh.R b/documentation-for-developers/refresh.R index 4bf1797..49a3b94 100644 --- a/documentation-for-developers/refresh.R +++ b/documentation-for-developers/refresh.R @@ -16,3 +16,8 @@ test_results_checked <- devtools::test() test_results_checked <- devtools::test(filter = "table-nih-enrollment") # testthat::test_dir("./tests/") test_results_not_checked <- testthat::test_dir("./tests/manual/") + +# devtools::check(force_suggests = FALSE) +# devtools::build_win(version="R-devel") #CRAN submission policies encourage the development version +# devtools::revdep_check(pkg="codified", recursive=TRUE) +# devtools::release(check=FALSE) #Careful, the last question ultimately uploads it to CRAN, where you can't delete/reverse your decision. diff --git a/inst/doc/nih-enrollment-html.R b/inst/doc/nih-enrollment-html.R index 6a0cae0..f1858f4 100644 --- a/inst/doc/nih-enrollment-html.R +++ b/inst/doc/nih-enrollment-html.R @@ -84,11 +84,19 @@ if( !requireNamespace("REDCapR", quietly=T) ) library(REDCapR) ## ----redcap-establish---------------------------------------------------- -ds_2 <- REDCapR::redcap_read_oneshot( - redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. - token = "F304DEC3793FECC3B6DEEFF66302CAD3", # User-speciifc token/password. - guess_type = FALSE # Keep all variables as strings/characters. -)$data +if( "0.9.8" < packageVersion("REDCapR") ) { + ds_2 <- REDCapR::redcap_read_oneshot( + redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. + token = "F304DEC3793FECC3B6DEEFF66302CAD3", # User-speciifc token/password. + guess_type = FALSE # Keep all variables as strings/characters. + )$data +} else { + # Older versions of REDCapR don't have the `guess_type` parameter + ds_2 <- REDCapR::redcap_read_oneshot( + redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. + token = "F304DEC3793FECC3B6DEEFF66302CAD3" # User-speciifc token/password. + )$data +} ## ----redcap-local-cosmetically-format------------------------------------ table_nih_enrollment_pretty( @@ -129,4 +137,3 @@ table_nih_enrollment_pretty( d_lu_race = ds_lu_race_3 ) - diff --git a/inst/doc/nih-enrollment-html.Rmd b/inst/doc/nih-enrollment-html.Rmd index 7470fc9..469dba3 100644 --- a/inst/doc/nih-enrollment-html.Rmd +++ b/inst/doc/nih-enrollment-html.Rmd @@ -138,11 +138,19 @@ library(REDCapR) Next, download the data from the REDCap database into the `ds_2` data.frame. ```{r redcap-establish} -ds_2 <- REDCapR::redcap_read_oneshot( - redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. - token = "F304DEC3793FECC3B6DEEFF66302CAD3", # User-speciifc token/password. - guess_type = FALSE # Keep all variables as strings/characters. -)$data +if( "0.9.8" < packageVersion("REDCapR") ) { + ds_2 <- REDCapR::redcap_read_oneshot( + redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. + token = "F304DEC3793FECC3B6DEEFF66302CAD3", # User-speciifc token/password. + guess_type = FALSE # Keep all variables as strings/characters. + )$data +} else { + # Older versions of REDCapR don't have the `guess_type` parameter + ds_2 <- REDCapR::redcap_read_oneshot( + redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. + token = "F304DEC3793FECC3B6DEEFF66302CAD3" # User-speciifc token/password. + )$data +} ``` @@ -195,8 +203,8 @@ table_nih_enrollment_pretty( d = ds_3, d_lu_race = ds_lu_race_3 ) - ``` + Feedback Welcome ===================================================== diff --git a/inst/doc/nih-enrollment-html.html b/inst/doc/nih-enrollment-html.html index ea71978..f2b135d 100644 --- a/inst/doc/nih-enrollment-html.html +++ b/inst/doc/nih-enrollment-html.html @@ -11,7 +11,7 @@ - + NIH Enrollment Tables in HTML @@ -1492,7 +1492,7 @@

NIH Enrollment Tables in HTML

Will Beasley and Peter Higgins

-

2018-09-05

+

2018-09-06

@@ -1525,236 +1525,137 @@

2.1 Establish Datasets

gender = as.character(gender), race = as.character(race), ethnicity = as.character(ethnicity) - ) -ds %>% + ) +
## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
+## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
+## length of NULL cannot be changed
+
ds %>% 
   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 -
record_idname_lastdobethnicityracegender
-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 -
1Cornel1991-05-13140
2Wojdyla1931-10-14140
3Stunkard1964-09-15131
4Cimochowski1969-05-03141
5Woodland1969-11-22140
6Pistoia1943-08-26141
7Ahlquist1944-01-22140
8Ashlin1931-04-14141
9Djokovic1962-07-07111
10Mosses1978-06-20130
@@ -1766,43 +1667,25 @@

2.1 Establish Datasets

) knitr::kable(ds_lu_gender, caption = "Gender Mapping") - + - - - + + + - - - + + + - - - + + + - - - + + +
-Gender Mapping -Gender Mapping
-input - -displayed -
inputdisplayed
-0 - -Female -
0Female
-1 - -Male -
1Male
-U - -Unknown/Not Reported -
UUnknown/Not Reported
@@ -1818,75 +1701,41 @@

2.1 Establish Datasets

) knitr::kable(ds_lu_race, caption = "Race Mapping") - + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + +
-Race Mapping -Race Mapping
-input - -displayed -
inputdisplayed
-1 - -American Indian/Alaska Native -
1American Indian/Alaska Native
-2 - -Asian -
2Asian
-3 - -Native Hawaiian or Other Pacific Islander -
3Native Hawaiian or Other Pacific Islander
-4 - -Black or African American -
4Black or African American
-5 - -White -
5White
-M - -More than One Race -
MMore than One Race
-6 - -Unknown or Not Reported -
6Unknown or Not Reported
@@ -1898,43 +1747,25 @@

2.1 Establish Datasets

) knitr::kable(ds_lu_ethnicity, caption = "Ethnicity Mapping") - + - - - + + + - - - + + + - - - + + + - - - + + +
-Ethnicity Mapping -Ethnicity Mapping
-input - -displayed -
inputdisplayed
-2 - -Not Hispanic or Latino -
2Not Hispanic or Latino
-1 - -Hispanic or Latino -
1Hispanic or Latino
-0 - -Unknown/Not Reported Ethnicity -
0Unknown/Not Reported Ethnicity
@@ -1950,907 +1781,393 @@

2.2 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 -
genderraceethnicityn
-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 -
FemaleAmerican Indian/Alaska NativeNot Hispanic or Latino1
FemaleAmerican Indian/Alaska NativeHispanic or Latino8
FemaleAmerican Indian/Alaska NativeUnknown/Not Reported Ethnicity0
FemaleAsianNot Hispanic or Latino0
FemaleAsianHispanic or Latino0
FemaleAsianUnknown/Not Reported Ethnicity0
FemaleNative Hawaiian or Other Pacific IslanderNot Hispanic or Latino1
FemaleNative Hawaiian or Other Pacific IslanderHispanic or Latino28
FemaleNative Hawaiian or Other Pacific IslanderUnknown/Not Reported Ethnicity3
FemaleBlack or African AmericanNot Hispanic or Latino1
FemaleBlack or African AmericanHispanic or Latino172
FemaleBlack or African AmericanUnknown/Not Reported Ethnicity14
FemaleWhiteNot Hispanic or Latino1
FemaleWhiteHispanic or Latino22
FemaleWhiteUnknown/Not Reported Ethnicity2
FemaleMore than One RaceNot Hispanic or Latino0
FemaleMore than One RaceHispanic or Latino0
FemaleMore than One RaceUnknown/Not Reported Ethnicity0
FemaleUnknown or Not ReportedNot Hispanic or Latino0
FemaleUnknown or Not ReportedHispanic or Latino7
FemaleUnknown or Not ReportedUnknown/Not Reported Ethnicity0
MaleAmerican Indian/Alaska NativeNot Hispanic or Latino0
MaleAmerican Indian/Alaska NativeHispanic or Latino10
MaleAmerican Indian/Alaska NativeUnknown/Not Reported Ethnicity0
MaleAsianNot Hispanic or Latino0
MaleAsianHispanic or Latino0
MaleAsianUnknown/Not Reported Ethnicity0
MaleNative Hawaiian or Other Pacific IslanderNot Hispanic or Latino1
MaleNative Hawaiian or Other Pacific IslanderHispanic or Latino22
MaleNative Hawaiian or Other Pacific IslanderUnknown/Not Reported Ethnicity1
MaleBlack or African AmericanNot Hispanic or Latino5
MaleBlack or African AmericanHispanic or Latino154
MaleBlack or African AmericanUnknown/Not Reported Ethnicity6
MaleWhiteNot Hispanic or Latino0
MaleWhiteHispanic or Latino33
MaleWhiteUnknown/Not Reported Ethnicity1
MaleMore than One RaceNot Hispanic or Latino0
MaleMore than One RaceHispanic or Latino0
MaleMore than One RaceUnknown/Not Reported Ethnicity0
MaleUnknown or Not ReportedNot Hispanic or Latino0
MaleUnknown or Not ReportedHispanic or Latino7
MaleUnknown or Not ReportedUnknown/Not Reported Ethnicity0
Unknown/Not ReportedAmerican Indian/Alaska NativeNot Hispanic or Latino0
Unknown/Not ReportedAmerican Indian/Alaska NativeHispanic or Latino0
Unknown/Not ReportedAmerican Indian/Alaska NativeUnknown/Not Reported Ethnicity0
Unknown/Not ReportedAsianNot Hispanic or Latino0
Unknown/Not ReportedAsianHispanic or Latino0
Unknown/Not ReportedAsianUnknown/Not Reported Ethnicity0
Unknown/Not ReportedNative Hawaiian or Other Pacific IslanderNot Hispanic or Latino0
Unknown/Not ReportedNative Hawaiian or Other Pacific IslanderHispanic or Latino0
Unknown/Not ReportedNative Hawaiian or Other Pacific IslanderUnknown/Not Reported Ethnicity0
Unknown/Not ReportedBlack or African AmericanNot Hispanic or Latino0
Unknown/Not ReportedBlack or African AmericanHispanic or Latino0
Unknown/Not ReportedBlack or African AmericanUnknown/Not Reported Ethnicity0
Unknown/Not ReportedWhiteNot Hispanic or Latino0
Unknown/Not ReportedWhiteHispanic or Latino0
Unknown/Not ReportedWhiteUnknown/Not Reported Ethnicity0
Unknown/Not ReportedMore than One RaceNot Hispanic or Latino0
Unknown/Not ReportedMore than One RaceHispanic or Latino0
Unknown/Not ReportedMore than One RaceUnknown/Not Reported Ethnicity0
Unknown/Not ReportedUnknown or Not ReportedNot Hispanic or Latino0
Unknown/Not ReportedUnknown or Not ReportedHispanic or Latino0
Unknown/Not ReportedUnknown or Not ReportedUnknown/Not Reported Ethnicity0
@@ -3166,12 +2483,20 @@

3.1 Establish Datasets

library(REDCapR)

Next, download the data from the REDCap database into the ds_2 data.frame.

-
ds_2 <- REDCapR::redcap_read_oneshot(
-  redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/",  # URL of REDCap Server.
-  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 0.7 seconds.  The http status code was 200.
+
if( "0.9.8" < packageVersion("REDCapR") ) {
+  ds_2 <- REDCapR::redcap_read_oneshot(
+    redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/",  # URL of REDCap Server.
+    token      = "F304DEC3793FECC3B6DEEFF66302CAD3",    # User-speciifc token/password.
+    guess_type = FALSE                                  # Keep all variables as strings/characters.
+  )$data  
+} else {
+  # Older versions of REDCapR don't have the `guess_type` parameter
+  ds_2 <- REDCapR::redcap_read_oneshot(
+    redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/",  # URL of REDCap Server.
+    token      = "F304DEC3793FECC3B6DEEFF66302CAD3"     # User-speciifc token/password.
+  )$data
+}
+
## 500 records and 13 columns were read from REDCap in 0.5 seconds.  The http status code was 200.

3.2 Conform to NIH Cosmetics

diff --git a/man/codified-package.Rd b/man/codified-package.Rd index 06ca3f3..af0867e 100644 --- a/man/codified-package.Rd +++ b/man/codified-package.Rd @@ -12,6 +12,7 @@ Augment clinical data with metadata to create \seealso{ Useful links: \itemize{ + \item \url{https://ouhscbbmc.github.io/codified/} \item \url{https://github.com/OuhscBbmc/codified} \item \url{https://github.com/higgi13425/nih_enrollment_table} \item Report bugs at \url{https://github.com/OuhscBbmc/codified/issues} diff --git a/vignettes/nih-enrollment-html.Rmd b/vignettes/nih-enrollment-html.Rmd index 7470fc9..469dba3 100644 --- a/vignettes/nih-enrollment-html.Rmd +++ b/vignettes/nih-enrollment-html.Rmd @@ -138,11 +138,19 @@ library(REDCapR) Next, download the data from the REDCap database into the `ds_2` data.frame. ```{r redcap-establish} -ds_2 <- REDCapR::redcap_read_oneshot( - redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. - token = "F304DEC3793FECC3B6DEEFF66302CAD3", # User-speciifc token/password. - guess_type = FALSE # Keep all variables as strings/characters. -)$data +if( "0.9.8" < packageVersion("REDCapR") ) { + ds_2 <- REDCapR::redcap_read_oneshot( + redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. + token = "F304DEC3793FECC3B6DEEFF66302CAD3", # User-speciifc token/password. + guess_type = FALSE # Keep all variables as strings/characters. + )$data +} else { + # Older versions of REDCapR don't have the `guess_type` parameter + ds_2 <- REDCapR::redcap_read_oneshot( + redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. + token = "F304DEC3793FECC3B6DEEFF66302CAD3" # User-speciifc token/password. + )$data +} ``` @@ -195,8 +203,8 @@ table_nih_enrollment_pretty( d = ds_3, d_lu_race = ds_lu_race_3 ) - ``` + Feedback Welcome ===================================================== From d0877697341c5d23fc3ce41ea27c5cd7d5d23afb Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 6 Sep 2018 22:33:50 -0500 Subject: [PATCH 2/4] promoting/eliminating some 'Suggests' packages --- DESCRIPTION | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 72b9bd8..231250e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,7 +13,10 @@ Depends: R(>= 3.0.0), stats Imports: + checkmate (>= 1.8.4), dplyr (>= 0.7.0), + kableExtra, + knitr (>= 1.18.0), magrittr, methods, readr (>= 1.1.0), @@ -21,14 +24,10 @@ Imports: tibble (>= 1.4.0), tidyr (>= 0.7.0) Suggests: - checkmate (>= 1.8.4), devtools, - kableExtra, - knitr (>= 1.18.0), REDCapR, rmarkdown, - sessioninfo, - testthat (>= 0.9) + testthat (>= 2.0) License: MIT + file LICENSE LazyData: TRUE VignetteBuilder: knitr From dbbaaecdf7642502e79994aae215bc243047ff55 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 6 Sep 2018 23:36:06 -0500 Subject: [PATCH 3/4] Correct title case; prepare cran submission --- DESCRIPTION | 2 +- NEWS.md | 1 + cran-comments.md | 31 +++ docs/articles/nih-enrollment-html.html | 242 +++++++++++------------ docs/reference/table_nih_enrollment.html | 10 +- inst/doc/nih-enrollment-html.R | 15 +- inst/doc/nih-enrollment-html.Rmd | 26 ++- inst/doc/nih-enrollment-html.html | 64 ++---- man/codified-package.Rd | 2 +- vignettes/nih-enrollment-html.Rmd | 26 ++- 10 files changed, 223 insertions(+), 196 deletions(-) create mode 100644 cran-comments.md diff --git a/DESCRIPTION b/DESCRIPTION index 231250e..69f6b67 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: codified -Title: Produce standard/formalized demographics tables +Title: Produce Standard/Formalized Demographics Tables Description: Augment clinical data with metadata to create output used in conventional publications and reports. Version: 0.2.0 diff --git a/NEWS.md b/NEWS.md index 81dda9a..9d84c50 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,3 +4,4 @@ * added `table_nih_enrollment()` and `table_nih_enrollment_pretty()`. #2 * added `nih-enrollment-html` vignette. #6 * started pkgdown site. #7 +* the idea was created by [Peter Higgins](http://www.med.umich.edu/higginslab/) (@higgi13425) for [R/Medicine 2018](http://r-medicine.com/). diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..0aedee5 --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,31 @@ +Description +----------------------------------------------- +This is a new release. + +Thank you for taking the time to review my submission, and please tell me if there's something else I should do for CRAN. -Will Beasley + + +Test environments +----------------------------------------------- + +The win-builder and a local machine have used the CRAN version of dplyr. The others have used the current GitHub master version of dplyr. + +* Local Ubuntu, R 3.5.1 patched +* [win-builder](https://win-builder.r-project.org/9fyA0Vz5XQNU/) (version="R-devel") +* [Travis CI](https://travis-ci.org/OuhscBbmc/codified), Ubuntu LTS +* [AppVeyor](https://ci.appveyor.com/project/wibeasley/codified), Windows Server + + +R CMD check results +----------------------------------------------- + +* No ERRORs or WARNINGs on any builds. + +* No NOTEs other than 'New submission' + + +Downstream dependencies +----------------------------------------------- + +No other packages depend/import this one. + diff --git a/docs/articles/nih-enrollment-html.html b/docs/articles/nih-enrollment-html.html index c05c5d9..8af2a79 100644 --- a/docs/articles/nih-enrollment-html.html +++ b/docs/articles/nih-enrollment-html.html @@ -122,45 +122,10 @@

gender = as.character(gender), race = as.character(race), ethnicity = as.character(ethnicity) - )

-
## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
ds %>% 
-  head(10) %>% 
-  knitr::kable(caption = "Observed Dataset (first ten rows)")
+ ) +ds %>% + head(10) %>% + knitr::kable(caption = "Observed Dataset (first ten rows)") @@ -254,13 +219,13 @@

Observed Dataset (first ten rows)
-
ds_lu_gender <- tibble::tribble(
-  ~input,   ~displayed            ,
-  "0"   ,  "Female"               , 
-  "1"   ,  "Male"                 ,
-  "U"   ,  "Unknown/Not Reported"
-)
-knitr::kable(ds_lu_gender, caption = "Gender Mapping")
+
ds_lu_gender <- tibble::tribble(
+  ~input,   ~displayed            ,
+  "0"   ,  "Female"               , 
+  "1"   ,  "Male"                 ,
+  "U"   ,  "Unknown/Not Reported"
+)
+knitr::kable(ds_lu_gender, caption = "Gender Mapping")
@@ -282,17 +247,17 @@

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"                         ,
-  "6"    , "Unknown or Not Reported"
-)
-knitr::kable(ds_lu_race, caption = "Race 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"                         ,
+  "6"    , "Unknown or Not Reported"
+)
+knitr::kable(ds_lu_race, caption = "Race Mapping")
@@ -330,13 +295,13 @@

Race Mapping
-
ds_lu_ethnicity <- tibble::tribble(
-  ~input,   ~displayed                      ,
-  "2"   ,  "Not Hispanic or Latino"         ,
-  "1"   ,  "Hispanic or Latino"             ,
-  "0"   ,  "Unknown/Not Reported Ethnicity"
-)
-knitr::kable(ds_lu_ethnicity, caption = "Ethnicity Mapping")
+
ds_lu_ethnicity <- tibble::tribble(
+  ~input,   ~displayed                      ,
+  "2"   ,  "Not Hispanic or Latino"         ,
+  "1"   ,  "Hispanic or Latino"             ,
+  "0"   ,  "Unknown/Not Reported Ethnicity"
+)
+knitr::kable(ds_lu_ethnicity, caption = "Ethnicity Mapping")
@@ -362,14 +327,14 @@

Ethnicity Mapping
@@ -763,12 +728,12 @@

Counts of Each Subgroup
@@ -1069,36 +1034,49 @@

Establish Datasets

First, install the REDCapR package if necessary, and then load it into memory.

-
if( !requireNamespace("REDCapR", quietly=T) )
-  devtools::install_github("OuhscBbmc/REDCapR")
-
-library(REDCapR)
-

Next, download the data from the REDCap database into the ds_2 data.frame.

-
if( "0.9.8" < packageVersion("REDCapR") ) {
-  ds_2 <- REDCapR::redcap_read_oneshot(
-    redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/",  # URL of REDCap Server.
-    token      = "F304DEC3793FECC3B6DEEFF66302CAD3",    # User-speciifc token/password.
-    guess_type = FALSE                                  # Keep all variables as strings/characters.
-  )$data  
-} else {
-  # Older versions of REDCapR don't have the `guess_type` parameter
-  ds_2 <- REDCapR::redcap_read_oneshot(
-    redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/",  # URL of REDCap Server.
-    token      = "F304DEC3793FECC3B6DEEFF66302CAD3"     # User-speciifc token/password.
-  )$data
-}
-
## 500 records and 13 columns were read from REDCap in 0.6 seconds.  The http status code was 200.
+
if( !requireNamespace("REDCapR", quietly=T) )
+  devtools::install_github("OuhscBbmc/REDCapR")
+
+library(REDCapR)
+

Next, download the data from the REDCap database into the ds_2 data.frame. If you’re running the most recent version of REDCapR (available on GitHub), the code will be:

+
ds_2 <- REDCapR::redcap_read_oneshot(
+  redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/",  # URL of REDCap Server.
+  token      = "F304DEC3793FECC3B6DEEFF66302CAD3",    # User-specific token/password.
+  guess_type = FALSE                                  # Keep all variables as strings/characters.
+)$data  
+

The following code is more complicated than normal, because the vignette has to account for different versions of REDCapR being installed on the machine.

+
if( !requireNamespace("REDCapR", quietly=TRUE) ) {
+  ds <- ds_2 # If REDCapR isn't installed, use the previous version of the dataset.
+} else if( "0.9.8" < packageVersion("REDCapR") ) {
+  ds_2 <- REDCapR::redcap_read_oneshot(
+    redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/",  # URL of REDCap Server.
+    token      = "F304DEC3793FECC3B6DEEFF66302CAD3",    # User-specific token/password.
+    guess_type = FALSE                                  # Keep all variables as strings/characters.
+  )$data  
+} else {
+  # Older versions of REDCapR don't have the `guess_type` parameter
+  ds_2 <- REDCapR::redcap_read_oneshot(
+    redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/",  # URL of REDCap Server.
+    token      = "F304DEC3793FECC3B6DEEFF66302CAD3"     # User-specific token/password.
+  )$data %>% 
+    dplyr::mutate(
+      gender      = as.character(gender),
+      race        = as.character(race),
+      ethnicity   = as.character(ethnicity)
+    )
+}
+
## 500 records and 13 columns were read from REDCap in 0.7 seconds.  The http status code was 200.

Conform to NIH Cosmetics

Now, convert these demographic data into a properly formatted NIH enrollment table. Pass the ds_lu_gender, ds_lu_race, and ds_lu_ethnicity metadata, which was defined above. As a reminder, these translate values like 1 to Male and 3 to Native Hawaiian or Other Pacific Islander.

- +
@@ -1395,35 +1373,35 @@

Collapsing Levels

Many observed datasets may collect race with a different set of levels. For instance in ds_3, the American Indian level is separate from the Alaska Native level. In the first and second rows in the metadata below, the two levels are effectively combined into theAmerican Indian/Alaska Native level, so it complies with the format of the NIH Enrollment table.

-
ds_lu_race_3 <- tibble::tribble(
-  ~input                      , ~displayed                                  ,
-  "American Indian"           , "American Indian/Alaska Native"             , # Combine w/ Alaska Native
-  "Alaska Native"             , "American Indian/Alaska Native"             , # Combine w/ American Indian
-  "Asian"                     , "Asian"                                     ,
-  "Native Hawaiian"           , "Native Hawaiian or Other Pacific Islander" , # Combine w/ Pacific Islanders
-  "Pacific Islander"          , "Native Hawaiian or Other Pacific Islander" , # Combine w/ Hawaiian
-  "Black or African American" , "Black or African American"                 ,
-  "White"                     , "White"                                     ,
-  "More than One Race"        , "More than One Race"                        ,
-  "Unknown or Not Reported"   , "Unknown or Not Reported"
-)
-
-ds_3 <- tibble::tribble(
-  ~subject_id,   ~gender  , ~race            ,  ~ethnicity                 ,
-           1L,   "Female" , "American Indian",  "Not Hispanic or Latino"   ,
-           2L,   "Male"   , "American Indian",  "Not Hispanic or Latino"   ,
-           3L,   "Male"   , "American Indian",  "Not Hispanic or Latino"   ,
-           4L,   "Female" , "Alaska Native"  ,  "Not Hispanic or Latino"   ,
-           5L,   "Male"   , "Alaska Native"  ,  "Not Hispanic or Latino"   ,
-           6L,   "Male"   , "Alaska Native"  ,  "Not Hispanic or Latino"   ,
-           7L,   "Male"   , "White"          ,  "Not Hispanic or Latino"   ,
-           8L,   "Male"   , "White"          ,  "Not Hispanic or Latino"        
-)
-
-table_nih_enrollment_pretty(
-  d               = ds_3,
-  d_lu_race       = ds_lu_race_3
-)
+
ds_lu_race_3 <- tibble::tribble(
+  ~input                      , ~displayed                                  ,
+  "American Indian"           , "American Indian/Alaska Native"             , # Combine w/ Alaska Native
+  "Alaska Native"             , "American Indian/Alaska Native"             , # Combine w/ American Indian
+  "Asian"                     , "Asian"                                     ,
+  "Native Hawaiian"           , "Native Hawaiian or Other Pacific Islander" , # Combine w/ Pacific Islanders
+  "Pacific Islander"          , "Native Hawaiian or Other Pacific Islander" , # Combine w/ Hawaiian
+  "Black or African American" , "Black or African American"                 ,
+  "White"                     , "White"                                     ,
+  "More than One Race"        , "More than One Race"                        ,
+  "Unknown or Not Reported"   , "Unknown or Not Reported"
+)
+
+ds_3 <- tibble::tribble(
+  ~subject_id,   ~gender  , ~race            ,  ~ethnicity                 ,
+           1L,   "Female" , "American Indian",  "Not Hispanic or Latino"   ,
+           2L,   "Male"   , "American Indian",  "Not Hispanic or Latino"   ,
+           3L,   "Male"   , "American Indian",  "Not Hispanic or Latino"   ,
+           4L,   "Female" , "Alaska Native"  ,  "Not Hispanic or Latino"   ,
+           5L,   "Male"   , "Alaska Native"  ,  "Not Hispanic or Latino"   ,
+           6L,   "Male"   , "Alaska Native"  ,  "Not Hispanic or Latino"   ,
+           7L,   "Male"   , "White"          ,  "Not Hispanic or Latino"   ,
+           8L,   "Male"   , "White"          ,  "Not Hispanic or Latino"        
+)
+
+table_nih_enrollment_pretty(
+  d               = ds_3,
+  d_lu_race       = ds_lu_race_3
+)
diff --git a/docs/reference/table_nih_enrollment.html b/docs/reference/table_nih_enrollment.html index 113c0b7..778d416 100644 --- a/docs/reference/table_nih_enrollment.html +++ b/docs/reference/table_nih_enrollment.html @@ -472,17 +472,17 @@

Examp ethnicity = as.character(ethnicity) )
#> Parsed with column specification: #> cols( -#> record_id = col_integer(), +#> record_id = col_double(), #> name_last = col_character(), #> name_first = col_character(), #> address = col_character(), #> phone = col_double(), #> dob = col_date(format = ""), -#> ethnicity = col_integer(), -#> race = col_integer(), -#> gender = col_integer(), +#> ethnicity = col_double(), +#> race = col_double(), +#> gender = col_double(), #> height_cm = col_double(), -#> weight_kg = col_integer(), +#> weight_kg = col_double(), #> email = col_character() #> )
ds_lu_gender <- tibble::tribble( diff --git a/inst/doc/nih-enrollment-html.R b/inst/doc/nih-enrollment-html.R index f1858f4..01b0aba 100644 --- a/inst/doc/nih-enrollment-html.R +++ b/inst/doc/nih-enrollment-html.R @@ -84,18 +84,25 @@ if( !requireNamespace("REDCapR", quietly=T) ) library(REDCapR) ## ----redcap-establish---------------------------------------------------- -if( "0.9.8" < packageVersion("REDCapR") ) { +if( !requireNamespace("REDCapR", quietly=TRUE) ) { + ds <- ds_2 # If REDCapR isn't installed, use the previous version of the dataset. +} else if( "0.9.8" < packageVersion("REDCapR") ) { ds_2 <- REDCapR::redcap_read_oneshot( redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. - token = "F304DEC3793FECC3B6DEEFF66302CAD3", # User-speciifc token/password. + token = "F304DEC3793FECC3B6DEEFF66302CAD3", # User-specific token/password. guess_type = FALSE # Keep all variables as strings/characters. )$data } else { # Older versions of REDCapR don't have the `guess_type` parameter ds_2 <- REDCapR::redcap_read_oneshot( redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. - token = "F304DEC3793FECC3B6DEEFF66302CAD3" # User-speciifc token/password. - )$data + token = "F304DEC3793FECC3B6DEEFF66302CAD3" # User-specific token/password. + )$data %>% + dplyr::mutate( + gender = as.character(gender), + race = as.character(race), + ethnicity = as.character(ethnicity) + ) } ## ----redcap-local-cosmetically-format------------------------------------ diff --git a/inst/doc/nih-enrollment-html.Rmd b/inst/doc/nih-enrollment-html.Rmd index 469dba3..c87a0df 100644 --- a/inst/doc/nih-enrollment-html.Rmd +++ b/inst/doc/nih-enrollment-html.Rmd @@ -135,21 +135,37 @@ if( !requireNamespace("REDCapR", quietly=T) ) library(REDCapR) ``` -Next, download the data from the REDCap database into the `ds_2` data.frame. +Next, download the data from the REDCap database into the `ds_2` data.frame. If you're running the most recent version of REDCapR (available on GitHub), the code will be: + +```r +ds_2 <- REDCapR::redcap_read_oneshot( + redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. + token = "F304DEC3793FECC3B6DEEFF66302CAD3", # User-specific token/password. + guess_type = FALSE # Keep all variables as strings/characters. +)$data +``` +The following code is more complicated than normal, because the vignette has to account for different versions of REDCapR being installed on the machine. ```{r redcap-establish} -if( "0.9.8" < packageVersion("REDCapR") ) { +if( !requireNamespace("REDCapR", quietly=TRUE) ) { + ds <- ds_2 # If REDCapR isn't installed, use the previous version of the dataset. +} else if( "0.9.8" < packageVersion("REDCapR") ) { ds_2 <- REDCapR::redcap_read_oneshot( redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. - token = "F304DEC3793FECC3B6DEEFF66302CAD3", # User-speciifc token/password. + token = "F304DEC3793FECC3B6DEEFF66302CAD3", # User-specific token/password. guess_type = FALSE # Keep all variables as strings/characters. )$data } else { # Older versions of REDCapR don't have the `guess_type` parameter ds_2 <- REDCapR::redcap_read_oneshot( redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. - token = "F304DEC3793FECC3B6DEEFF66302CAD3" # User-speciifc token/password. - )$data + token = "F304DEC3793FECC3B6DEEFF66302CAD3" # User-specific token/password. + )$data %>% + dplyr::mutate( + gender = as.character(gender), + race = as.character(race), + ethnicity = as.character(ethnicity) + ) } ``` diff --git a/inst/doc/nih-enrollment-html.html b/inst/doc/nih-enrollment-html.html index f2b135d..62ee2f3 100644 --- a/inst/doc/nih-enrollment-html.html +++ b/inst/doc/nih-enrollment-html.html @@ -1525,43 +1525,8 @@

2.1 Establish Datasets

gender = as.character(gender), race = as.character(race), ethnicity = as.character(ethnicity) - ) -
## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
-## Warning in read_tokens_(data, tokenizer, col_specs, col_names, locale_, :
-## length of NULL cannot be changed
-
ds %>% 
+  )
+ds %>% 
   head(10) %>% 
   knitr::kable(caption = "Observed Dataset (first ten rows)")

@@ -2482,21 +2447,34 @@

3.1 Establish Datasets

devtools::install_github("OuhscBbmc/REDCapR") library(REDCapR) -

Next, download the data from the REDCap database into the ds_2 data.frame.

-
if( "0.9.8" < packageVersion("REDCapR") ) {
+

Next, download the data from the REDCap database into the ds_2 data.frame. If you’re running the most recent version of REDCapR (available on GitHub), the code will be:

+
ds_2 <- REDCapR::redcap_read_oneshot(
+  redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/",  # URL of REDCap Server.
+  token      = "F304DEC3793FECC3B6DEEFF66302CAD3",    # User-specific token/password.
+  guess_type = FALSE                                  # Keep all variables as strings/characters.
+)$data  
+

The following code is more complicated than normal, because the vignette has to account for different versions of REDCapR being installed on the machine.

+
if( !requireNamespace("REDCapR", quietly=TRUE) ) {
+  ds <- ds_2 # If REDCapR isn't installed, use the previous version of the dataset.
+} else if( "0.9.8" < packageVersion("REDCapR") ) {
   ds_2 <- REDCapR::redcap_read_oneshot(
     redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/",  # URL of REDCap Server.
-    token      = "F304DEC3793FECC3B6DEEFF66302CAD3",    # User-speciifc token/password.
+    token      = "F304DEC3793FECC3B6DEEFF66302CAD3",    # User-specific token/password.
     guess_type = FALSE                                  # Keep all variables as strings/characters.
   )$data  
 } else {
   # Older versions of REDCapR don't have the `guess_type` parameter
   ds_2 <- REDCapR::redcap_read_oneshot(
     redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/",  # URL of REDCap Server.
-    token      = "F304DEC3793FECC3B6DEEFF66302CAD3"     # User-speciifc token/password.
-  )$data
+    token      = "F304DEC3793FECC3B6DEEFF66302CAD3"     # User-specific token/password.
+  )$data %>% 
+    dplyr::mutate(
+      gender      = as.character(gender),
+      race        = as.character(race),
+      ethnicity   = as.character(ethnicity)
+    )
 }
-
## 500 records and 13 columns were read from REDCap in 0.5 seconds.  The http status code was 200.
+
## 500 records and 13 columns were read from REDCap in 0.8 seconds.  The http status code was 200.

3.2 Conform to NIH Cosmetics

diff --git a/man/codified-package.Rd b/man/codified-package.Rd index af0867e..6a3deab 100644 --- a/man/codified-package.Rd +++ b/man/codified-package.Rd @@ -4,7 +4,7 @@ \name{codified-package} \alias{codified} \alias{codified-package} -\title{codified: Produce standard/formalized demographics tables} +\title{codified: Produce Standard/Formalized Demographics Tables} \description{ Augment clinical data with metadata to create output used in conventional publications and reports. diff --git a/vignettes/nih-enrollment-html.Rmd b/vignettes/nih-enrollment-html.Rmd index 469dba3..c87a0df 100644 --- a/vignettes/nih-enrollment-html.Rmd +++ b/vignettes/nih-enrollment-html.Rmd @@ -135,21 +135,37 @@ if( !requireNamespace("REDCapR", quietly=T) ) library(REDCapR) ``` -Next, download the data from the REDCap database into the `ds_2` data.frame. +Next, download the data from the REDCap database into the `ds_2` data.frame. If you're running the most recent version of REDCapR (available on GitHub), the code will be: + +```r +ds_2 <- REDCapR::redcap_read_oneshot( + redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. + token = "F304DEC3793FECC3B6DEEFF66302CAD3", # User-specific token/password. + guess_type = FALSE # Keep all variables as strings/characters. +)$data +``` +The following code is more complicated than normal, because the vignette has to account for different versions of REDCapR being installed on the machine. ```{r redcap-establish} -if( "0.9.8" < packageVersion("REDCapR") ) { +if( !requireNamespace("REDCapR", quietly=TRUE) ) { + ds <- ds_2 # If REDCapR isn't installed, use the previous version of the dataset. +} else if( "0.9.8" < packageVersion("REDCapR") ) { ds_2 <- REDCapR::redcap_read_oneshot( redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. - token = "F304DEC3793FECC3B6DEEFF66302CAD3", # User-speciifc token/password. + token = "F304DEC3793FECC3B6DEEFF66302CAD3", # User-specific token/password. guess_type = FALSE # Keep all variables as strings/characters. )$data } else { # Older versions of REDCapR don't have the `guess_type` parameter ds_2 <- REDCapR::redcap_read_oneshot( redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", # URL of REDCap Server. - token = "F304DEC3793FECC3B6DEEFF66302CAD3" # User-speciifc token/password. - )$data + token = "F304DEC3793FECC3B6DEEFF66302CAD3" # User-specific token/password. + )$data %>% + dplyr::mutate( + gender = as.character(gender), + race = as.character(race), + ethnicity = as.character(ethnicity) + ) } ``` From eb3e35da7127daeabc40ba9c8dc2ba5197d0e805 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 6 Sep 2018 23:52:50 -0500 Subject: [PATCH 4/4] correct spelling --- R/table-nih-enrollment.R | 2 +- man/table_nih_enrollment.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/table-nih-enrollment.R b/R/table-nih-enrollment.R index b65e69c..47def13 100644 --- a/R/table-nih-enrollment.R +++ b/R/table-nih-enrollment.R @@ -1,7 +1,7 @@ #' @name table_nih_enrollment #' @aliases table_nih_enrollment table_nih_enrollment_pretty #' -#' @title Produce an NIH-compliant enrolment table. +#' @title Produce an NIH-compliant enrollment table. #' #' @description Produce an NIH enrollment table, leveraging metadata to adapt to the observed [data.frame]. #' diff --git a/man/table_nih_enrollment.Rd b/man/table_nih_enrollment.Rd index 81f76f2..3ee3b30 100644 --- a/man/table_nih_enrollment.Rd +++ b/man/table_nih_enrollment.Rd @@ -3,7 +3,7 @@ \name{table_nih_enrollment} \alias{table_nih_enrollment} \alias{table_nih_enrollment_pretty} -\title{Produce an NIH-compliant enrolment table.} +\title{Produce an NIH-compliant enrollment table.} \usage{ table_nih_enrollment(d, d_lu_gender = NULL, d_lu_race = NULL, d_lu_ethnicity = NULL, variable_gender = "gender",