knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
A collection of clinical research organization (CRO) miscellaneous functions developed for The Prostate Cancer Clinical Trials Consortium (PCCTC).
⚠️ This package is under active development! Feedback is welcome, consistency is not yet promised.
You can install the development version of croquet from GitHub with:
# install.packages("devtools") devtools::install_github("pcctc/croquet")
Brief variable names are useful for coding, but might not provide sufficient context for collaborators. Here, we add variable labels data and export those labels to an excel sheet to make content more readily digestible.
library(croquet) library(openxlsx) # format all date and date time variables in the excel output options("openxlsx.dateFormat" = "yyyy-mm-dd") options("openxlsx.datetimeFormat" = "yyyy-mm-dd")
dat1 <- tibble::tibble( var_1 = 1:3, var_2 = LETTERS[1:3], var_3 = Sys.Date() - 0:2 ) %>% labelled::set_variable_labels( var_1 = "Variable 1 (numeric)", var_2 = "Variable 2 (character)", var_3 = "Variable 3 (date)" ) dat2 <- tibble::tibble( var_1 = 4:6, var_2 = LETTERS[4:6], var_3 = Sys.Date() - 0:2 ) %>% labelled::set_variable_labels( var_1 = "Variable 1 (numeric)", var_2 = "Variable 2 (character)", var_3 = "Variable 3 (date)" )
# initialize workbook wb <- createWorkbook() # default settings name sheet by name of input data add_labelled_sheet(dat1) # you can rename sheet to something more meaningful add_labelled_sheet(dat1, "example sheet") saveWorkbook(wb, "check-wb-1.xlsx")
# create named list out <- tibble::lst(dat1, dat2) # initialize workbook wb <- createWorkbook() # create labelled sheets from all input data add_labelled_sheet(out) saveWorkbook(wb, "check-wb-2.xlsx")
#| fig.cap: > #| Screenshot of resulting excel output. #| fig.alt: > #| Shows two tabs named dat1 and dat2. Row 1 has light gray italics text and #| white background; row 2 has a black background and white text. knitr::include_graphics("man/figures/check-wb-2.PNG")
Needs more documentation!
This imports a single sheet that assumes variables labels are in row 1 and variable
names are row 2. You can optionally specify a regex expression for date_detect
to identify variables that should be explicitly imported as a date.
dat <- read_labelled_sheet( path = here::here(path, dsn1), sheet = "ae_listings", date_detect = "cyc1_visdat|cyc2_visdat" )
knitr::knit_exit()
You'll still need to render README.Rmd
regularly, to keep README.md
up-to-date. devtools::build_readme()
is handy for this. You could also use GitHub Actions to re-render README.Rmd
every time you push. An example workflow can be found here: https://github.com/r-lib/actions/tree/v1/examples.
You can also embed plots, for example:
plot(pressure)
In that case, don't forget to commit and push the resulting figure files, so they display on GitHub and CRAN.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.