RandomExp function

Randomized Experimental Designs

Randomized Experimental Designs

Randomizes subjects into treatment groups according to specified criteria.

RandomExp(data,sizes=NULL,groups=NULL,block=NULL,seed=NULL)

Arguments

  • data: A data frame containing the subjects to be randomized
  • sizes: a numeric vector indicating the sizes of the treatment groups. Vector must sum to the number of subjects. If not provided, subjects will be randomized into two groups of size as nearly equal as possible.
  • groups: a character vector giving the names of the groups. Names correspond to sizes specified in previous sizes. Length of groups must equal length of sizes.
  • block: Variable(s) in the data frame with respect to which blocking is performed. In order to block with respect to more than one variable at once, enter as character vector, e.g.: c("Var1","Var2").
  • seed: randomization seed, for reproducibility of results.

Returns

A data frame: the input frame data augmented with a variable treat.grp indicating the assignment of subjects to groups.

Examples

data(SmallExp) #small hypothetical list of subjects #completely randomized design RandomExp(SmallExp) #Block with reppect to sex: RandomExp(SmallExp,sizes=c(8,8),groups=letters[1:2],block="sex") #Block for both sex and athletic status: RandomExp(SmallExp,sizes=c(8,8),groups=letters[1:2],block=c("sex","athlete"))

Author(s)

Homer White hwhite0@georgetowncollege.edu

  • Maintainer: Homer White
  • License: GPL (>= 3)
  • Last published: 2020-06-15

Useful links