package randomizeBE for R on steroids [🇷 for BE/BA]
❝ By the function randomizeBE the result appears like this:
❝ Example: seed 2047732 blocksize: 2 created: 2018-02-24 12:38:06
Function
RL4()
of package randomizeBE
generates a list containing as one of its elements the data frame rl
. You can manipulate it as you like: Add a column for sex, shuffle it, and assign new subject numbers. If you want to see what is going on behind the scenes, uncomment the print
-lines.library(randomizeBE)
n <- 16
blocksize <- n/2
random <- RL4(nsubj=n, seqs=c("TR", "RT"),
blocksize=blocksize, randctrl=TRUE)
random$rl <- cbind(random$rl, sex="F", stringsAsFactors=FALSE) # "F" default
# change second half to "M"
random$rl$sex[which(random$rl$subject > blocksize)] <- "M"
# print(random$rl, row.names=FALSE) # intermediate
random$rl <- random$rl[sample(nrow(random$rl)), ] # shuffle
# print(random$rl, row.names=FALSE) # intermediate
random$rl$subject <- 1:n # new subject numbers
print(random) # final
Gave on my machine without a specified seed (i.e., based on the system clock and the process ID)
Randomization table created: 2018-02-24 17:51:34
(seed: 7952217 blocksize: 8 )
subject seqno sequence sex
1 1 TR F
2 2 RT M
3 1 TR F
4 1 TR M
5 2 RT F
6 1 TR F
7 2 RT M
8 2 RT M
9 1 TR M
10 1 TR M
11 2 RT M
12 2 RT F
13 1 TR F
14 2 RT F
15 1 TR M
16 2 RT F
You have to give the code in the SAP. Otherwise an assessor will not be able to reproduce it.
If you want to get output similar to your original post, add these lines before the final
print(random)
random$rl <- cbind(random$rl, per.1=NA, per.2=NA)
random$rl$per.1 <- paste0(substring(random$rl$sequence, 1, 1), " ")
random$rl$per.2 <- paste0(substring(random$rl$sequence, 2, 2), " ")
random$rl$sequence <- NULL
random$rl <- random$rl[, c("subject", "sex", "seqno", "per.1", "per.2")]
names(random$rl) <- c("sujeito", "sexo", "seq", "period 1", "period 2")
to get:
Randomization table created: 2018-02-24 17:51:34
(seed: 7952217 blocksize: 8 )
sujeito sexo seq period 1 period 2
1 F 1 T R
2 M 2 R T
3 F 1 T R
4 M 1 T R
5 F 2 R T
6 F 1 T R
7 M 2 R T
8 M 2 R T
9 M 1 T R
10 M 1 T R
11 M 2 R T
12 F 2 R T
13 F 1 T R
14 F 2 R T
15 M 1 T R
16 F 2 R T
Edit: Don’t use this code. For an update see this post.
Dif-tor heh smusma 🖖🏼 Довге життя Україна!
![[image]](https://static.bebac.at/pics/Blue_and_yellow_ribbon_UA.png)
Helmut Schütz
![[image]](https://static.bebac.at/img/CC by.png)
The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes
Complete thread:
- randomization Ana Cristina 2018-02-23 21:33 [🇷 for BE/BA]
- randomization ElMaestro 2018-02-23 22:24
- randomization Ana Cristina 2018-02-24 16:47
- randomization ElMaestro 2018-02-24 17:32
- package randomizeBE for R on steroidsHelmut 2018-02-24 17:52
- Randomization of gender d_labes 2018-02-26 11:56
- Simplified R-code Helmut 2018-02-26 15:46
- Simplified R-code Ana Cristina 2018-02-27 13:16
- Updated R-code Helmut 2018-02-27 17:06
- Gender in crossover d_labes 2018-02-28 08:43
- Gender in crossover nobody 2018-02-28 10:14
- Sex in crossover Helmut 2018-02-28 12:42
- Sex in crossover Helmut 2018-02-28 12:27
- OT: Sex / gender d_labes 2018-02-28 14:42
- OT: Sex / gender Helmut 2018-02-28 14:58
- OT: Sex / gender Ana Cristina 2018-03-01 03:16
- OT: Sex / gender Helmut 2018-02-28 14:58
- OT: Sex / gender d_labes 2018-02-28 14:42
- Gender in crossover nobody 2018-02-28 10:14
- Updated R-code Beholder 2020-04-08 12:31
- Gender in crossover d_labes 2018-02-28 08:43
- Updated R-code Helmut 2018-02-27 17:06
- Simplified R-code Ana Cristina 2018-02-27 13:16
- Simplified R-code Helmut 2018-02-26 15:46