-
Notifications
You must be signed in to change notification settings - Fork 14
/
io19_randomization_blockrand_CAPTURE.Rmd
101 lines (80 loc) · 2.7 KB
/
io19_randomization_blockrand_CAPTURE.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
---
title: "R Notebook"
output: html_notebook
editor_options:
chunk_output_type: inline
---
This is an example of use of the blockrand package to create a randomization of two assignments with 5 strata in a randomized permuted block design
```{r setup}
library(blockrand)
library(knitr)
library(kableExtra)
library(tidyverse, quietly = T)
```
Our goal is to have 500 assignments available across 5 strata.
```{r}
set.seed(1234)
stratum1 <- blockrand(n = 100,
block.prefix = "B_",
stratum = "Stratum_1",
num.levels = 2,
levels = c("Patient Navigator", "Control")
) %>% filter(id <101)
stratum1
```
Now stratum 2
```{r}
set.seed(0714)
stratum2 <- blockrand(n = 100,
block.prefix = "B_",
stratum = "Stratum_2",
num.levels = 2,
levels = c("Patient Navigator", "Control")
) %>% filter(id <101)
stratum2
```
Now stratum 3
```{r}
set.seed(1965)
stratum3 <- blockrand(n = 100,
block.prefix = "B_",
stratum = "Stratum_3",
num.levels = 2,
levels = c("Patient Navigator", "Control")
) %>% filter(id <101)
stratum3
```
Now stratum 4
```{r}
set.seed(314159)
stratum4 <- blockrand(n = 100,
block.prefix = "B_",
stratum = "Stratum_4",
num.levels = 2,
levels = c("Patient Navigator", "Control")
) %>% filter(id <101)
stratum4
```
Now Stratum 5
```{r}
set.seed(2718)
stratum5 <- blockrand(n = 100,
block.prefix = "B_",
stratum = "Stratum_5",
num.levels = 2,
levels = c("Patient Navigator", "Control")
) %>% filter(id <101)
stratum5
```
now bind these together in one assignment sheet
```{r}
assign500 <- rbind(stratum1, stratum2, stratum3, stratum4, stratum5)
assign500 %>%
rename(num = id) %>%
select(stratum, num, treatment, block.id, block.size) %>%
knitr::kable() %>%
kable_styling()
```
Add a new chunk by clicking the *Insert Chunk* button on the toolbar or by pressing *Cmd+Option+I*.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the *Preview* button or press *Cmd+Shift+K* to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike *Knit*, *Preview* does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.