-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdata_loaders.R
39 lines (34 loc) · 1.27 KB
/
data_loaders.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
load.training.data <- function(filename) {
data <- read.csv(file=filename)
data$race <- data$grp %% 2
data$cholratio <- data$totchol / data$hdl
data$ldl <- data$totchol - data$hdl
return(data)
}
load.test.data <- function(filename) {
data <- read.csv(file=filename)
data$race <- data$grp %% 2
data$cholratio <- data$totchol / data$hdl
data$ldl <- data$totchol - data$hdl
return(data)
}
load.nhanes <- function(filename) {
nhanesdata = read.table(filename, head=TRUE, sep=",")
nhanesdata$sysbp <- nhanesdata$sbp
nhanesdata$bmi <- nhanesdata$bmxbmi
nhanesdata$cursmoke <- nhanesdata$tob
nhanesdata$cholmed <- nhanesdata$statin
nhanesdata$study <- "NHANES"
nhanesdata$grp <- nhanesdata$cohort
nhanesdata$race <- nhanesdata$grp %% 2
nhanesdata$ldl <- nhanesdata$totchol - nhanesdata$hdl
nhanesdata$cholratio <- nhanesdata$totchol / nhanesdata$hdl
nhanesdata$weightvar = nhanesdata$weightvar
nhanesdata = nhanesdata[complete.cases(nhanesdata),]
nhanesdata <- subset(nhanesdata,
20 < hdl & hdl < 100 &
130 < totchol & totchol < 320 &
90 < sysbp & sysbp < 200 &
39 < age & age <= 79)
return(nhanesdata)
}