\begin{Schunk}
\begin{Sinput}
 ## Two groups, first = 0 or 1
 set.seed(123)
 firstprop <- 0.4
 dat <- data.frame(first = rbinom(n = 100, size = 1, prob = firstprop))
 ## We have just assigned rows of data into groups labeled 1 and 0
 head(dat)
\end{Sinput}
\begin{Soutput}
  first
1     0
2     1
3     0
4     1
5     1
6     0
\end{Soutput}
\begin{Sinput}
 ## Now we sample IQ scores, taking group membership into account.
 ## Here we use vectorized inputs to the data generator
 dat$IQ <- rnorm(NROW(dat), m = 98 + 5 * dat$first, sd = 15)
 ## round to nearest whole number, since that is how IQ scores are
 ## reported
 dat$IQ <- round(dat$IQ)
 head(dat, 10)
\end{Sinput}
\begin{Soutput}
   first  IQ
1      0 102
2      1 103
3      0  97
4      1 124
5      1 100
6      0 121
7      0  75
8      1 112
9      0 100
10     0 101
\end{Soutput}
\end{Schunk}
