Import, primary coding and export functions for data of the National Pandemic Cohort Network NAPKON.
The latest versions of epicodr can be found here: Releases
Using this package, you can import SÜP, HAP and POP data exported from SecuTrial by the Transfer-Office, set variable and value labels, format date variables, perform primary coding, as well as export the data, e.g. in SPSS format.
You can find a tutorial on how to use this package on YouTube at NUKLEUS ECU.
- Install a R runtime environment and git on your computer. Provide Internet access.
- Create a R file and put the following code inside:
# Install package remotes
if(!require(remotes)) install.packages("remotes")
# Install package epicodr
# replace "release" with a specific version, if necessary
# See section *Versions* for more details
remotes::install_github("nukleus-ecu/epicodr@*release")
# Load package epicodr
library(epicodr)
# Specifiy location where to find data zip file
zip_file_path <- "data/import/NAME_OF_EXPORT_FILE.zip"
# Import the zip file data
data <- zip_file_path %>%
read_tsExport(separator = ";", decimal = ",")
# Execute primary coding on data
data_primary_coded <- data %>%
# place coding function accordingly, e.g., primary_coding_suep() or primary_coding_hap() or primary_coding_pop()
primary_coding_suep()
# Note: SPSS only supports levels of variables with <= 120 characters
# Set affected variables to NULL
# e.g.
data_primary_coded$fuv3$disab_ecog.factor <- NULL
# Export the prepared data in R to formats of other statistical software e.g. SPSS (sav) to export folder
# For other formats replace "sav" with (one of "dta", "sas", "sav", "xpt")
write_tsExport(data_primary_coded, format = "sav", path = "data/export/", metadata = TRUE)
- Run the script.
- Data is exported to folder data/export.
- Install a R runtime environment and git on your computer. Provide Internet access.
- Clone this repository:
git clone https://github.com/nukleus-ecu/epicodr.git
- Export data from secuTrial and place the *.zip file in data/import/.
- Open and run script R/run/sample.R for sample import, primary coding and SPSS export or create a new R script by yourself.
- Data is exported to folder data/export.
Descriptions of the primary codings of the NAPKON cohort platforms SÜP, POP and HAP are available at the following link:
Additionally, there are manuals that include variable categorizations, aids for calculating scores, defining normal ranges of laboratory parameters and clinical parameters. Further explanations are also available in the tutorial presentation.
This repository is structured as follows:
- R contains all R code
- data/import is the place to put raw datasets, i.e. secuTrial exports
- data/export is the place where exported datasets are stored
- doc contains further documentation
- lib contains external libraries
- resources contains static content such as images
- tests contains unit tests
The R code is structured as follows:
- R/*.R contains platform independent implementations:
- 10-preprocess-zip.R contains a function to preprocess the exported zip
- 20-import-secutrial.R contains secutrial import functions
- 30-primary-coding.R contains platformindependent helper fuctions used in platform specific primary coding scripts
- 40-render.R contains a function for rendering reports
- 41-render-diagrams.R contains a function for rendering diagrams
- 52-render-helpers.R contains a workaround to replace NAs in order to be able to generate tables with createTableOne without loosing rows due to all NAs in a data frame column
- R/hap contains HAP specific implementations
- R/pop contains POP specific implementations
- R/suep contains SÜP specific implementations
Inside R/suep, the code is structured as follows:
- run contains all run scripts, e.g. to code and export to SPSS format
- 30-primary-coding.R implements the primary coding of suep
- XX-export.R contains export functions, e.g. in SPSS format
Inside R/hap, the code is structured as follows:
- run contains all run scripts, e.g. to code and export to SPSS format
- 30-primary-coding.R implements the primary coding of hap
- XX-export.R contains export functions, e.g. in SPSS format
Inside R/pop, the code is structured as follows:
- run contains all run scripts, e.g. to code and export to SPSS format
- 30-primary-coding.R implements the primary coding of hap
- XX-export.R contains export functions, e.g. in SPSS format