-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
182 lines (146 loc) · 4.32 KB
/
index.Rmd
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
---
title: "**RvAC** | Randomization and virtual Allocation Concealment"
name: CFT-PLT-trial
---
```{css, echo = FALSE}
body {
font-size: 2em;
}
div.main-container {
max-width: 1280px;
margin-left: auto;
margin-right: auto;
}
```
<!-- disable href after 1 click on html -->
<script>
function clickAndDisable(link) {
// disable subsequent clicks
link.onclick = function(event) {
event.preventDefault();
}
}
</script>
## {.unlist .unnumbered .tabset}
<br>
### **Registered protocol**
<br>
<iframe src="https://clinicaltrials.gov/ct2/show/NCT05480982" style="width:100%; height:600px;"></iframe>
<br>
*Fontes:* [**ClinicalTrials.gov**](https://clinicaltrials.gov/ct2/show/NCT05480982)
<br>
### **Randomization**
#### *1. Generate list using block randomization*
```{r rand-alloc, echo = TRUE, include = TRUE, comment = NA, warning = FALSE, message = FALSE, fig.align = 'center', out.width = "100%"}
# load packages
library("blockrand", character.only = TRUE)
library("png", character.only = TRUE)
library("writexl", character.only = TRUE)
# reproducible results
seed <- 2020
set.seed(seed)
# sample size
N <- 200
# groups
grupos <- c("CFT", "PLT")
K = length(grupos)
# blocks
B <- 10 / K
# randomize
lista <- blockrand(
N,
num.levels = K,
# treatments
levels = grupos,
# treatment names
block.sizes = seq(1:B)
)
lista <- as.data.frame(lista)
# save list im disk
write_xlsx(lista, "lista_alocacao.xlsx")
```
<br>
#### *2. Check for balanced allocation*
```{r rand-alloc-check-1, echo = TRUE, include = TRUE, comment = NA, warning = FALSE, message = FALSE, fig.align = 'center', out.width = "100%", eval = FALSE}
print("Participants per group, n:", quote = FALSE)
print(table(lista[, 4]), quote = FALSE)
print("Participants per group, %", quote = FALSE)
print(table(lista[, 4])/sum(summary(lista[, 4]))*100, quote = FALSE)
```
```{r rand-alloc-check-2, echo = FALSE, include = TRUE, comment = NA, warning = FALSE, message = FALSE, fig.align = 'center', out.width = "100%", eval = TRUE}
print("Participants per group, n:", quote = FALSE)
print(table(lista[, 4]), quote = FALSE)
print("Participants per group, %", quote = FALSE)
print(table(lista[, 4])/sum(summary(lista[, 4]))*100, quote = FALSE)
```
<br>
#### *3. Generate folders with envelopes*
```{r rand-alloc-hide, echo = TRUE, include = TRUE, comment = NA, warning = FALSE, message = FALSE, fig.align = 'center', out.width = "100%"}
# load packages
library("fontawesome", character.only = TRUE)
library("grid", character.only = TRUE)
# create dir with eachvirtual envelopes (folders) following the randomization list
for (i in 1:dim(lista)[1]) {
# set participant ID
dir.name <- formatC(lista$id[i], width = 3, flag = "0")
# create dir
dir.create(file.path("ids"))
# create subdir
dir.create(file.path("ids", dir.name))
# maxime plot 'envelope' area
par(mar = c(0, 0, 0, 0))
par(mai = c(0, 0, 0, 0))
par(oma = c(0, 0, 0, 0))
par(width = 3,
height = 4,
unit = "in")
# initialize image
png(file = file.path("ids", dir.name, paste0(dir.name, ".png")), bg = "transparent")
plot(
NULL,
xlim = c(-1, 1),
ylim = c(-1, 1),
ylab = NA,
xlab = NA,
bty = "n",
axes = FALSE,
frame.plot = TRUE,
asp = 1
)
text(
x = 0,
y = 0,
labels = lista$treatment[i],
cex = 10
)
title(paste0('Participant ID ', dir.name), cex.main = 4)
grid.roundrect(
height = 0.99,
width = 0.99,
gp = gpar(fill = "#00000000", col = "grey", lwd = 2)
)
dev.off()
}
```
<br>
### **Allocation concealment**
<br>
```{r rand-alloc-show, , echo = FALSE, include = TRUE, comment = NA, warning = FALSE, message = FALSE, fig.align = 'center', out.width = "100%", results = "asis"}
# load packages
library("fontawesome", character.only = TRUE)
# exibe a lista em formato de hyperlink
for (i in 1:dim(lista)[1]) {
dir.name <- formatC(lista$id[i], width = 3, flag = "0")
cat('<a style=\"margin:auto;\" href=\"',
file.path("ids", dir.name, paste0(dir.name, ".png")),
'\" target="_blank" rel=\"noopener\" onclick=\"return confirm(\'Are you sure you want to open an envelope for PARTICIPANT ID ',
dir.name,
'?\')\">',
fa("user", height = "1.5em", width = "1.5em", margin_right = "0.2em"),
'Participant ID ', dir.name,
'</a>',
sep = "")
cat('\n\n')
cat('\n\n')
}
```