Learn R Programming

blockTools (version 0.1)

assignment: Randomly assign blocked units to treatment conditions

Description

Using an output object from block, assign elements of each row to treatment condition columns. Each element is equally likely to be assigned to each column.

Usage

assignment(block.obj, seed = NULL, namesCol = NULL)

Arguments

block.obj
an output object from block, or a user-specified block object.
seed
a user-specified random seed.
namesCol
an optional vector of column names for the output table.

Details

block.obj can be specified directly by the user. It can be a single dataframe or matrix with blocks as rows and treatment conditions as columns. assignment is designed to take a list with two elements. The first element should be named {$blocks, and should be a list of dataframes. Each dataframe should have blocks as rows and treatment conditions as columns. The second element should be a logical named {$level.two. Specifying the random seed yields constant assignment, and thus allows for easy replication of experimental protocols.

If namesCol = NULL, then ``Treatment 1", ``Treatment 2", ...are used. }

A list of dataframes, each containing a group's blocked units assigned to treatment conditions. If there are two treatment conditions, then the last column of each dataframe displays the multivariate distance between the two units. If there are more than two treatment conditions, then the last column of each dataframe displays the largest of the multivariate distances between all possible pairs in the block.

[object Object]

block, diagnose data(x100)

## First, block out <- block(x100, groups = "g", n.tr = 2, id.vars = c("id"), block.vars = c("b1", "b2"), algorithm="optGreedy", distance = "mahalanobis", level.two = FALSE, valid.var = "b1", valid.range = c(0,500), verbose = TRUE) ## Second, assign assg <- assignment(out, seed = 123) ## assg contains 3 data frames

design