Skip to content

Instantly share code, notes, and snippets.

library(tidyverse)
set.seed(1)
Untreated <- rnorm(20, 20, sd = 5) #Outcome among the treated: 20 observations from N(20,25)
Treated <- rnorm(20,15, sd = 5) #Outcome among the untreated: 20 observations from N(15,25)
Outcome <- c(Treated, Untreated)
trt.num <- c(rep(0,20), rep(1,20)) #A=0 if untreated, A=1 if treated
df <- as.data.frame(cbind(as.numeric(Outcome), as.numeric(trt.num)))
df.summary <- as.data.frame(cbind(c(mean(Treated), mean(Untreated)), c(1,2)))
colnames(df) <- c('Outcome', 'Treatment')