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")
Screenshot of resulting excel output.
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"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.