Warfarin

Data Sets

Info

Original Form

Download Warfarin (Original)

Original Data Set

> head(warfarin)
   ID TIME WEIGHT AGE SEX CMT AMT DVID  DV MDV MDVPK
1 100  0.0   66.7  50   1   1 100    1  NA   1     1
2 100  0.5   66.7  50   1   2  NA    1 0.0   0     0
3 100  1.0   66.7  50   1   2  NA    1 1.9   0     0
4 100  2.0   66.7  50   1   2  NA    1 3.3   0     0
5 100  3.0   66.7  50   1   2  NA    1 6.6   0     0
6 100  6.0   66.7  50   1   2  NA    1 9.1   0     0

Massage Data

Changes that NEED to be made

Final Form

Download warfarin.mdvpk.1(Source the file)
> head(warfarin.mdvpk.1)
    ID TIME WEIGHT AGE SEX CMT AMT DVID DV MDV MDVPK DOSE
1  100    0   66.7  50   1   1 100    1 NA   1     1  100
10 100   24   66.7  50   1   2   0    2 44   0     1  100
12 100   36   66.7  50   1   2   0    2 27   0     1  100
14 100   48   66.7  50   1   2   0    2 28   0     1  100
16 100   72   66.7  50   1   2   0    2 31   0     1  100
17 100   96   66.7  50   1   2   0    2 60   0     1  100
Download warfarin.mdvpk.0(Source the file)
> head(warfarin.mdvpk.0)
   ID TIME WEIGHT AGE SEX CMT AMT DVID   DV MDV MDVPK DOSE
2 100  0.5   66.7  50   1   2   0    1  0.0   0     0  100
3 100  1.0   66.7  50   1   2   0    1  1.9   0     0  100
4 100  2.0   66.7  50   1   2   0    1  3.3   0     0  100
5 100  3.0   66.7  50   1   2   0    1  6.6   0     0  100
6 100  6.0   66.7  50   1   2   0    1  9.1   0     0  100
7 100  9.0   66.7  50   1   2   0    1 10.8   0     0  100

Code

Code to alter Warfarin to fit the requests above

warfarin <- read.csv(file.choose())		### warfarin.txt
warfarin[is.na(warfarin["AMT"]),"AMT"] <- 0

tmp <- as.character(warfarin$ID)
tmp.split <- split(warfarin,warfarin["ID"])

final <- NULL
for( i in unique(tmp)){
  section <- rep(tmp.split[[i]][1,"AMT"],nrow(tmp.split[[i]]))
  final <- c(final,section)
}
DOSE <- final
warfarin <- cbind(warfarin, DOSE)

warfarin.mdvpk.0 <- warfarin[ warfarin$MDVPK==0,]
warfarin.mdvpk.1 <- warfarin[ warfarin$MDVPK==1,]

warfarin.mdvpk.0   #No AMT data (warfarin.mdvpk.0["AMT"]==0)
warfarin.mdvpk.1