addBMI: Adding BMI data to your final file

Description Usage Arguments Details Value Examples

Description

This function takes your dataset (crea.rep or similar) and aligns BMI event.dates with creatinine measurement event.dates. It will add a BMI column with NAs at the beginning and then fill it with corresponding BMI values while running. It loops through each patient ID, finds all event.dates and CodeValues for BMI in this patient, finds the closest event.date to creatinine event.date (not necessarily after the creatinine event), and saves this BMI value. It is saving a new dataframe row by row, in every loop.

Usage

1
addBMI(crea.dataset, bmi.dataset, NbOfCores = 4L, filename)

Arguments

crea.dataset

dataset with creatinine ReadCodes, at least three creatinine measurements per patient.

bmi.dataset

file with extracted BMI codes from SIR data (codes starting with" 22K"); duplicates removed, NA free. All columns from SIR data can be present.

NbOfCores

how much cores do you want to use for your parallel process? Will be added to getOption() from mclapply. Default is 4 (should work on any PC), but can be changed to less or more.

filename

name of the final .txt file your output will be saved to. Can be a path also. Should be a txt file because of write.table function inside.

Details

This function uses parallel lapply - mclapply from "parallel" package. It's recommended to either run it in the background of your PC or on the cluster. The column used for time analysis is named "event.date".

Value

This function returns output file of mclapply function. Can be useful to save the output to a file in case an error occurrs because you can find error details in the output file. The creatinine data with BMI is automatically saved to a .txt file, row by row, and can later be accessed by using "read.table" function.

Examples

1
2
3
4
5
6
## Not run: 
addBMI(crea.dataset, bmi.dataset, NbOfCores =  4L, filename = "creaWithBMI.txt")
running the script in your background:
nohup Rscript myscript.R &

## End(Not run)

dkurtoic/addVariables documentation built on May 30, 2019, 8:28 a.m.