Learn R Programming

OptimalDesign (version 1.0.1)

od_pool: Pool of a vector

Description

A function pool.fun is applied to all the elements of a vector val that appear within the groups formed by identical rows of a matrix X.

Usage

od_pool(X, val=NULL, pool.fun="sum", echo=TRUE)

Value

A list with components:

call

the call of the function

X.unique

the matrix of unique rows of X

val.pooled

the vector of the length nrows(X.unique) containing the values of val pooled using pool.fun

Arguments

X

the n times k matrix of real values.

val

a real vector of length n.

pool.fun

a string denoting the function to be applied to the subgroups of elements of val corresponding to the identical rows of X. Possible values are "sum", "min", "max", "mean", "median" and "0".

echo

Print the call of the function?

Author

Radoslav Harman, Lenka Filova

Details

This function is useful for plotting (and understanding) of designs of experiments with more factors than the dimension of the plot.

See Also

od_plot, od_print

Examples

Run this code
v1 <- c(1, 2, 3); v2 <- c(2, 4, 6); v3 <- c(2, 5, 3)
X <- rbind(v1, v1, v1, v1, v2, v3, v2, v3, v3)
val <- c(1, 2, 7, 9, 5, 8, 4, 3, 6)
od_pool(X, val, "sum")

# The result $val.pooled is a vector with components:
# 19 (=1+2+7+9) because the first 4 rows of X are identical
# 9 (=5+4) because the 5th and the 7th rows of X are identical
# 17 (=8+3+6) because the 6th, the 8th and the 9th rows of X are identical

Run the code above in your browser using DataLab