```{R, echo=FALSE} knitr::opts_chunk$set(comment = NA, message = FALSE, warning = FALSE, width = 100) knitr::opts_chunk$set(fig.align = "center", fig.height = 4, fig.width = 6) knitr::opts_chunk$set(echo = TRUE)

knitr::opts_chunk$set(cache = TRUE, autodep=TRUE) #$

knitr::opts_chunk$set(cache = FALSE) #, autodep=TRUE) #$

# Installing from source

Set the appropriate path and run this command:
```r
devtools::install_github("erikerhardt/CastorR")

Strategy for labeling factor variables

  1. Read data
    • Read all CRF_export.xlsx file sheets and construct the structures to produce an Rdata file with (1) variable question labels, (2) correct factor levels with labels, and (3) correct data and numeric data types.
    • Data in Study results has labels in Study variable list
    • Data in other data sheets (between Study results and Study variable list) has labels in Report variable list
    • All factor groups with labels and levels are in Field options
  2. Collect Option group names, levels, and labels
    • Field options gives the factor variable levels and labels
    • Option group name
    • Option name labels list with Option value list
  3. Assign variable question labels, Factor variables with Option groups, assign varible class data types
    • Study variable list gives the question names for Study results
    • Report variable list gives the question names for other data sheets (between Study results and Study variable list)
    • Variable name
    • Field label is the question name
    • Use library(labelled) with var_label()
    • For each variable, label it.
    • Optiongroup name
    • Use factor() for each variable using Option group name labels and levels
    • Field type variable data class, useful for date, datetime, and numeric.

Format Castor CRF data

library(CastorR)
dat <- castor_format_R(fn = "CRF_export_2.xlsx")
str(dat)


erikerhardt/CastorR documentation built on May 4, 2019, 7:42 p.m.