Description Usage Arguments Value Examples
View source: R/SphereKaji20140527.R
Utility function to handle tables with cells whose expected value is 0
1 | reshape.table(A, A.ori)
|
A |
an array or matrix of table, that may be the table with cells whose expected value is zero (0 cells) or that may be the table without such cells |
A.ori |
if missing(default), A represetnts a table with 0 cell(s) and the function converts A to a table without 0 cell(s). Otherwise, A should be a table without 0 cell(s) and A.ori is the original array/matrix before shrinkage. of table with 0 cells |
An array or matrix of table. if A.ori is missing, shrunken table is returned otherwise a table with 0 cells recovered. with 0 cells.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | n <- 5
M <- list()
N <-100
for(i in 1:n){
M[[i]] <- sample(0:5,sample(2:4,1))
M[[i]] <- M[[i]]/sum(M[[i]])*N
}
tmp <- M[[1]]
for(i in 2:length(M)){
tmp <- t(M[[i]]/N) %x% tmp
}
A <- array(tmp,lapply(M,length))
A.r <- reshape.table(A)
A.2 <- reshape.table(A.r,A)
calc.marg(A)
calc.marg(A.r)
calc.marg(A.2)
A-A.2
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.