dToCount: Functions to switch between count and array representation of...

View source: R/util_functions.R

dToCount.RdR Documentation

Functions to switch between count and array representation of an array

Description

dToCount rearranges an array into count vector format. countToDmixed rearranges a count vector representation into an array.

Usage

dToCount(d, nlevels=NULL, startfrom1=FALSE)
countToDmixed(nlevels, count)
ff(...)

Arguments

d

an array (matrix with runs as rows and factors as columns)

nlevels

vector of integers (>=2); numbers of factor levels

startfrom1

logical; if TRUE, values are from 1 to nlevels; the default is that values are from 0 to nlevel -1

count

vector of prod(nlevels) nonnegative integers;
the number of times the respective run of the full factorial in lexicographic order (as produced by ff(nlevels)) occurs in the array

...

vector of integers (>=2) or the integers themselves, separated by commata

Details

dToCount transforms an array into count representation. If all array columns contain all potential factor levels, nlevels does not need to be specified. Otherwise, nlevels is needed.

countToDmixed transforms the count representation of an array (counts refer to the rows of ff(nlevels)) into an array

Value

dToCount produces a vector of length prod(nlevels),
countToDmixed produces a matrix with sum(count) rows and length(nlevels) columns,
countToDmixed produces a matrix with prod(nlevels) rows and length(nlevels) columns.

Note

The size of the full factorial design (produced with ff) is a limiting factor for using the functionality of this package.

Author(s)

Ulrike Groemping

References

Groemping, U. (2020). DoE.MIParray: an R package for algorithmic creation of orthogonal arrays. Journal of Open Research Software, 8: 24. DOI: https://doi.org/10.5334/jors.286

Examples

d <- ff(c(2,2,4))[1:6,]   ## first six rows of the full factorial only
d
## the count vector must have 2*2*4=16 elements,
## the first six must be 1, the last ten must be zero
dToCount(d)               ## does not produce the desired result,
                          ## because the first column of d
                          ## does not contain both levels
(d_as_count <- dToCount(d, nlevels=c(2,2,4)))
                          ## corresponds to the above way of creating d
dToCount(d, nlevels=c(2,2,5))  ## would correspond to a different reality,
                               ## where the third factor has in fact 5 levels,
                               ## of which only four are in the array
countToDmixed(c(2,2,4), d_as_count)
                          ## creates d from the count representation

DoE.MIParray documentation built on Aug. 21, 2023, 5:08 p.m.