-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdjDoseFun_int.R
executable file
·58 lines (32 loc) · 1.37 KB
/
AdjDoseFun_int.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#Functions to re-adjust the Adj_dose column.
#You need to first call ChangeDosestoNumeric.R
#Each study has a different dose interval. In order to be able to compare doses of different studies,
#the equivalent dose if the dose interval was "day" is computed.
#When the dosing interval changes during the duration of the study,
#you keep the last dosing interval
AdjDoseFun_row=function(dose, dose_interval) {
if (dose_interval=="day") {
return(dose)
}else if (dose_interval=="week"){
return(round(dose/7,digits = 2))
}else if (dose_interval=="qod") {
return(round(dose/2,digits = 2))
}else if (dose_interval=="bi weekly") {
return(round(dose/14,digits = 2))
}else if (dose_interval=="every four days") {
return(round(dose/4,digits = 2))
}else if (dose_interval=="every four weeks") {
return(round(dose/28,digits = 2))
} else if (dose_interval=="twice weekly") {
return(round(dose/4,digits = 2))
}else if (dose_interval=="every five days") {
return(round(dose/5,digits = 2))
} else if (dose_interval== "bi weekly / every four weeks") {
return(round(dose/28,digits = 2))
}
}
AdjDose_intervalFun=function(dataf) {
Adj.dose=mapply(AdjDoseFun_row,as.vector(dataf$adj_dose),as.vector(dataf$dose_interval))
dataf$adj_dose=Adj.dose
return(dataf)
}