block and assignment functions
into an object in the format of one output by the seqblock function. This allows the
user to block and assign multiple units at the beginning of an experiment (using block and
assignment) and then sequentially block and assign more units to the experiment over time
(using seqblock).block2seqblock(block.obj, assg.obj, data, exact.restr = NULL, covar.restr = NULL, covar.order = NULL, trn = NULL, apstat = "mean", mtrim = 0.1, apmeth = "ktimes", kfac = 2, assgpr = c(0.5, 0.5), distance = NULL, datetime = NULL, orig, seed = NULL, file.name = "sbout.RData", verbose = FALSE)block, or a user-specified block objectassignment, or a user-specified assignment objectexact.restr is a vector containing all of the possible values that the first exact blocking variable can take on; the second element is a vector containing all of the possible values for the second exact blocking variable; and so oncovar.restr is a vector containing all of the possible values that the first non-exact blocking variable can take on; the second element is a vector containing all of the possible values for the second non-exact blocking variable; and so on"trimmean".x returned by the function as part of the bdata listbdata) with elementsblock.obj, assg.obj and data. Then, block2seqblock uses the call to block, the assignment object, and the original data to create an object that is ready to be input into seqblock.If the user explicitly specifies groups, id.vars and block.vars in the initial block function that is used to create the block.obj, block2seqblock will order the variables in the output it produces according to the order specified in the initial block function call. If the user does not explicitly specify the blocking variables in the block function call, block2seqblock will order the variables according to the order in the initial matrix or dataframe that was used to run the original block function.
As part of the function, variables that are of class factor in the original matrix or dataframe specified in data, will be converted into class character.
The trn argument uses the n.tr argument from block to extract the names of the treatment variables. Most other arguments are set to default values that mirror those in the seqblock function. One exception is the datetime argument, which defaults to a vector of NA's instead of the current datetime.
block, assignment, seqblock# data(x100)
# out <- block(x100, n.tr = 2, id.vars = c("id"), block.vars = c("b1", "b2"),
# algorithm = "optGreedy", distance = "mahalanobis", valid.var = "b1", valid.range = c(0,500))
# assg.out <- assignment(out, seed = 123)
# b2sb <- block2seqblock(block.obj = out, assg.obj = assg.out, data = x100)
# sb <- seqblock("sbout.RData", id.vals = 1101, covar.vals = c(100, 200), file.name = "sb101.RData")
Run the code above in your browser using DataLab