[R] Random Block
arun
smartpink111 at yahoo.com
Tue May 27 20:42:25 CEST 2014
Hi,
Please post in plain text and show the example using ?dput.
Assuming that you wanted a "data.frame" and not a "list"
May be this helps:
set.seed(428)
dat1 <- data.frame(`block identifier`=rep(1:40,each=12),`block size`=12,`sequence within block`=rep(1:12,40), treatment=sample(paste("Group", LETTERS[1:2]), 12*40, replace=TRUE),age65= rep(sample(c("yes","no"), 40, replace=TRUE),each=12), surgery = rep(sample(c("yes","no"),40, replace=TRUE), each=12), smoke=rep(sample(c("Yes","No"), 40, replace=TRUE), each=12), check.names=FALSE,stringsAsFactors=FALSE)
A.K.
Dear R-listers,
I am using R 3.1, I amtrying to generate 40 patients in each treatment group with 12 block, Equal number of treatment in each block ,using stratification Variable age65(yes, no),surgery(yes ,no) and smoke (yes, no)
How can i creat like thislist in R.
block identifier
block size
sequence within block
treatment
age65
surgery
smoke
1
12
1
Group B
yes
yes
Yes
1
12
2
Group A
yes
yes
Yes
1
12
3
Group A
yes
yes
Yes
1
12
4
Group B
yes
yes
Yes
1
12
5
Group A
yes
yes
Yes
1
12
6
Group B
yes
yes
Yes
1
12
7
Group B
yes
yes
Yes
1
12
8
Group A
yes
yes
Yes
1
12
9
Group A
yes
yes
Yes
1
12
10
Group B
yes
yes
Yes
1
12
11
Group A
yes
yes
Yes
1
12
12
Group B
yes
yes
Yes
2
12
1
Group B
yes
yes
no
2
12
2
Group A
yes
yes
no
2
12
3
Group B
yes
yes
no
2
12
4
Group B
yes
yes
no
2
12
5
Group A
yes
yes
no
2
12
6
Group A
yes
yes
no
2
12
7
Group B
yes
yes
no
2
12
8
Group A
yes
yes
no
2
12
9
Group A
yes
yes
no
2
12
10
Group B
yes
yes
no
2
12
11
Group A
yes
yes
no
2
12
12
Group B
yes
yes
no
I am very appreciate yourtime to answer my question
Thanks
Sug
More information about the R-help
mailing list