Allocating treatment to the each subjects [closed]












-2















I have four strata (stratum1, stratum2, stratum3, and stratum4) and I want to perform this code for each stratum in a loop and add the variable to a data frame



Strat1_Stratum1_Treat <- block_ra(blocks = ProjectData1$Stratum1,
prob = .5, conditions = c("A","B"))


check the nature of the data










share|improve this question















closed as unclear what you're asking by Wimpel, MLavoie, greg-449, Rob, Foo Nov 14 '18 at 14:38


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.



















  • It would be helpful if you could share the smallest amount of data to reproduce the question

    – Raoul Van Oosten
    Nov 14 '18 at 7:56











  • Please tell us what the package you use. Nobody knows where the function block_ra comes from.

    – Darren Tsai
    Nov 14 '18 at 8:30
















-2















I have four strata (stratum1, stratum2, stratum3, and stratum4) and I want to perform this code for each stratum in a loop and add the variable to a data frame



Strat1_Stratum1_Treat <- block_ra(blocks = ProjectData1$Stratum1,
prob = .5, conditions = c("A","B"))


check the nature of the data










share|improve this question















closed as unclear what you're asking by Wimpel, MLavoie, greg-449, Rob, Foo Nov 14 '18 at 14:38


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.



















  • It would be helpful if you could share the smallest amount of data to reproduce the question

    – Raoul Van Oosten
    Nov 14 '18 at 7:56











  • Please tell us what the package you use. Nobody knows where the function block_ra comes from.

    – Darren Tsai
    Nov 14 '18 at 8:30














-2












-2








-2


1






I have four strata (stratum1, stratum2, stratum3, and stratum4) and I want to perform this code for each stratum in a loop and add the variable to a data frame



Strat1_Stratum1_Treat <- block_ra(blocks = ProjectData1$Stratum1,
prob = .5, conditions = c("A","B"))


check the nature of the data










share|improve this question
















I have four strata (stratum1, stratum2, stratum3, and stratum4) and I want to perform this code for each stratum in a loop and add the variable to a data frame



Strat1_Stratum1_Treat <- block_ra(blocks = ProjectData1$Stratum1,
prob = .5, conditions = c("A","B"))


check the nature of the data







r loops






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 8:14







Jackline

















asked Nov 14 '18 at 7:32









JacklineJackline

145




145




closed as unclear what you're asking by Wimpel, MLavoie, greg-449, Rob, Foo Nov 14 '18 at 14:38


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as unclear what you're asking by Wimpel, MLavoie, greg-449, Rob, Foo Nov 14 '18 at 14:38


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.















  • It would be helpful if you could share the smallest amount of data to reproduce the question

    – Raoul Van Oosten
    Nov 14 '18 at 7:56











  • Please tell us what the package you use. Nobody knows where the function block_ra comes from.

    – Darren Tsai
    Nov 14 '18 at 8:30



















  • It would be helpful if you could share the smallest amount of data to reproduce the question

    – Raoul Van Oosten
    Nov 14 '18 at 7:56











  • Please tell us what the package you use. Nobody knows where the function block_ra comes from.

    – Darren Tsai
    Nov 14 '18 at 8:30

















It would be helpful if you could share the smallest amount of data to reproduce the question

– Raoul Van Oosten
Nov 14 '18 at 7:56





It would be helpful if you could share the smallest amount of data to reproduce the question

– Raoul Van Oosten
Nov 14 '18 at 7:56













Please tell us what the package you use. Nobody knows where the function block_ra comes from.

– Darren Tsai
Nov 14 '18 at 8:30





Please tell us what the package you use. Nobody knows where the function block_ra comes from.

– Darren Tsai
Nov 14 '18 at 8:30












1 Answer
1






active

oldest

votes


















0














Example Data



blocks <- sample(0:1, 40, TRUE)
data <- as.data.frame(matrix(blocks, 10, 4))
data

# V1 V2 V3 V4
# 1 0 1 1 1
# 2 0 0 0 0
# 3 1 1 0 1
# 4 0 0 0 1
# 5 1 1 1 1
# 6 1 1 0 1
# 7 0 0 0 0
# 8 1 0 0 0
# 9 0 0 1 0
# 10 0 0 0 0


Use lapply() to conduct a function for each variable.



data[5:8] <- lapply(data, block_ra, prob = .5, conditions = c("A", "B"))
data

# V1 V2 V3 V4 V1.1 V2.1 V3.1 V4.1
# 1 0 1 1 1 A A B B
# 2 0 0 0 0 B B B B
# 3 1 1 0 1 A A A A
# 4 0 0 0 1 B A B B
# 5 1 1 1 1 B B A A
# 6 1 1 0 1 A B B A
# 7 0 0 0 0 B A B A
# 8 1 0 0 0 B B A B
# 9 0 0 1 0 A A B A
# 10 0 0 0 0 A B A B





share|improve this answer
























  • Awesome it worked perfectly

    – Jackline
    Nov 14 '18 at 16:24


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Example Data



blocks <- sample(0:1, 40, TRUE)
data <- as.data.frame(matrix(blocks, 10, 4))
data

# V1 V2 V3 V4
# 1 0 1 1 1
# 2 0 0 0 0
# 3 1 1 0 1
# 4 0 0 0 1
# 5 1 1 1 1
# 6 1 1 0 1
# 7 0 0 0 0
# 8 1 0 0 0
# 9 0 0 1 0
# 10 0 0 0 0


Use lapply() to conduct a function for each variable.



data[5:8] <- lapply(data, block_ra, prob = .5, conditions = c("A", "B"))
data

# V1 V2 V3 V4 V1.1 V2.1 V3.1 V4.1
# 1 0 1 1 1 A A B B
# 2 0 0 0 0 B B B B
# 3 1 1 0 1 A A A A
# 4 0 0 0 1 B A B B
# 5 1 1 1 1 B B A A
# 6 1 1 0 1 A B B A
# 7 0 0 0 0 B A B A
# 8 1 0 0 0 B B A B
# 9 0 0 1 0 A A B A
# 10 0 0 0 0 A B A B





share|improve this answer
























  • Awesome it worked perfectly

    – Jackline
    Nov 14 '18 at 16:24
















0














Example Data



blocks <- sample(0:1, 40, TRUE)
data <- as.data.frame(matrix(blocks, 10, 4))
data

# V1 V2 V3 V4
# 1 0 1 1 1
# 2 0 0 0 0
# 3 1 1 0 1
# 4 0 0 0 1
# 5 1 1 1 1
# 6 1 1 0 1
# 7 0 0 0 0
# 8 1 0 0 0
# 9 0 0 1 0
# 10 0 0 0 0


Use lapply() to conduct a function for each variable.



data[5:8] <- lapply(data, block_ra, prob = .5, conditions = c("A", "B"))
data

# V1 V2 V3 V4 V1.1 V2.1 V3.1 V4.1
# 1 0 1 1 1 A A B B
# 2 0 0 0 0 B B B B
# 3 1 1 0 1 A A A A
# 4 0 0 0 1 B A B B
# 5 1 1 1 1 B B A A
# 6 1 1 0 1 A B B A
# 7 0 0 0 0 B A B A
# 8 1 0 0 0 B B A B
# 9 0 0 1 0 A A B A
# 10 0 0 0 0 A B A B





share|improve this answer
























  • Awesome it worked perfectly

    – Jackline
    Nov 14 '18 at 16:24














0












0








0







Example Data



blocks <- sample(0:1, 40, TRUE)
data <- as.data.frame(matrix(blocks, 10, 4))
data

# V1 V2 V3 V4
# 1 0 1 1 1
# 2 0 0 0 0
# 3 1 1 0 1
# 4 0 0 0 1
# 5 1 1 1 1
# 6 1 1 0 1
# 7 0 0 0 0
# 8 1 0 0 0
# 9 0 0 1 0
# 10 0 0 0 0


Use lapply() to conduct a function for each variable.



data[5:8] <- lapply(data, block_ra, prob = .5, conditions = c("A", "B"))
data

# V1 V2 V3 V4 V1.1 V2.1 V3.1 V4.1
# 1 0 1 1 1 A A B B
# 2 0 0 0 0 B B B B
# 3 1 1 0 1 A A A A
# 4 0 0 0 1 B A B B
# 5 1 1 1 1 B B A A
# 6 1 1 0 1 A B B A
# 7 0 0 0 0 B A B A
# 8 1 0 0 0 B B A B
# 9 0 0 1 0 A A B A
# 10 0 0 0 0 A B A B





share|improve this answer













Example Data



blocks <- sample(0:1, 40, TRUE)
data <- as.data.frame(matrix(blocks, 10, 4))
data

# V1 V2 V3 V4
# 1 0 1 1 1
# 2 0 0 0 0
# 3 1 1 0 1
# 4 0 0 0 1
# 5 1 1 1 1
# 6 1 1 0 1
# 7 0 0 0 0
# 8 1 0 0 0
# 9 0 0 1 0
# 10 0 0 0 0


Use lapply() to conduct a function for each variable.



data[5:8] <- lapply(data, block_ra, prob = .5, conditions = c("A", "B"))
data

# V1 V2 V3 V4 V1.1 V2.1 V3.1 V4.1
# 1 0 1 1 1 A A B B
# 2 0 0 0 0 B B B B
# 3 1 1 0 1 A A A A
# 4 0 0 0 1 B A B B
# 5 1 1 1 1 B B A A
# 6 1 1 0 1 A B B A
# 7 0 0 0 0 B A B A
# 8 1 0 0 0 B B A B
# 9 0 0 1 0 A A B A
# 10 0 0 0 0 A B A B






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 8:25









Darren TsaiDarren Tsai

2,1261427




2,1261427













  • Awesome it worked perfectly

    – Jackline
    Nov 14 '18 at 16:24



















  • Awesome it worked perfectly

    – Jackline
    Nov 14 '18 at 16:24

















Awesome it worked perfectly

– Jackline
Nov 14 '18 at 16:24





Awesome it worked perfectly

– Jackline
Nov 14 '18 at 16:24



Popular posts from this blog

Bressuire

Vorschmack

Quarantine