https://github.com/pcctc/croquet
Miscellaneous operations for PCCTC, a Clinical Research Organization (CRO)
https://github.com/pcctc/croquet
Last synced: 4 months ago
JSON representation
Miscellaneous operations for PCCTC, a Clinical Research Organization (CRO)
- Host: GitHub
- URL: https://github.com/pcctc/croquet
- Owner: pcctc
- License: other
- Created: 2021-12-08T15:23:17.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-09T21:22:28.000Z (7 months ago)
- Last Synced: 2024-08-09T22:33:49.536Z (7 months ago)
- Language: R
- Homepage: https://pcctc.github.io/croquet/
- Size: 1.42 MB
- Stars: 6
- Watchers: 3
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - pcctc/croquet - Miscellaneous operations for PCCTC, a Clinical Research Organization (CRO) (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# croquet
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[](https://CRAN.R-project.org/package=croquet)
[](https://app.codecov.io/gh/pcctc/croquet?branch=main)
[](https://github.com/pcctc/croquet/actions/workflows/R-CMD-check.yaml)A collection of clinical research organization (CRO) miscellaneous functions
developed for [The Prostate Cancer Clinical Trials Consortium (PCCTC)](https://pcctc.org/).## Installation
⚠️ This package is under active development! Feedback is welcome, consistency is not yet promised.
You can install the development version of croquet from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("pcctc/croquet")
```## Exporting labelled data to excel
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.### Libraries
```{r}
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")
```### Example data
```{r example-data}
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)"
)
```### Export single sheet
```{r export-single, eval=FALSE}
# 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")
```### Export multiple sheets
```{r export-multiple, eval=FALSE}
# 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")
``````{r img-wb-2, eval=TRUE, echo=FALSE}
#| 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")
```## Importing labelled data from excel
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.```{r import-labelled-sheet, eval=FALSE}
dat <- read_labelled_sheet(
path = here::here(path, dsn1),
sheet = "ae_listings",
date_detect = "cyc1_visdat|cyc2_visdat"
)
``````{r, echo = FALSE}
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: .
You can also embed plots, for example:
```{r pressure, echo = FALSE}
plot(pressure)
```In that case, don't forget to commit and push the resulting figure files, so they display on GitHub and CRAN.