Commit 779e296a authored by Gjalt-Jorn Peters's avatar Gjalt-Jorn Peters
Browse files

better CIM

parent 08802277
Pipeline #225570992 failed with stage
in 5 minutes and 37 seconds
...@@ -179,7 +179,7 @@ CIM <- function(data, ...@@ -179,7 +179,7 @@ CIM <- function(data,
cfa1s = list(), cfa1s = list(),
cfa2s = list(), cfa2s = list(),
cfas = list(), cfas = list(),
diamondplots = list(), factorLoadingPlots = list(),
faDfs = list(), faDfs = list(),
scales = scales, scales = scales,
abbrScales = abbrScales, abbrScales = abbrScales,
...@@ -201,7 +201,7 @@ CIM <- function(data, ...@@ -201,7 +201,7 @@ CIM <- function(data,
res$intermediate$cfa1s[[rowVar]] <- list(); res$intermediate$cfa1s[[rowVar]] <- list();
res$intermediate$cfa2s[[rowVar]] <- list(); res$intermediate$cfa2s[[rowVar]] <- list();
res$intermediate$cfas[[rowVar]] <- list(); res$intermediate$cfas[[rowVar]] <- list();
res$intermediate$diamondplots[[rowVar]] <- list(); res$intermediate$factorLoadingPlots[[rowVar]] <- list();
res$intermediate$faDfs[[rowVar]] <- list(); res$intermediate$faDfs[[rowVar]] <- list();
### Get index of this row ### Get index of this row
...@@ -447,7 +447,7 @@ CIM <- function(data, ...@@ -447,7 +447,7 @@ CIM <- function(data,
faDf <- faDf <-
as.data.frame( as.data.frame(
unclass( unclass(
res$intermediate$efas[[rowVar]][[colVar]] res$intermediate$efas[[rowVar]][[colVar]]$loadings
) )
); );
...@@ -515,7 +515,7 @@ CIM <- function(data, ...@@ -515,7 +515,7 @@ CIM <- function(data,
if (n.iter > 1) { if (n.iter > 1) {
grobsList[[rowIndex]][[colIndex]] <- grobsList[[rowIndex]][[colIndex]] <-
res$intermediate$diamondplots[[rowVar]][[colVar]] <- res$intermediate$factorLoadingPlots[[rowVar]][[colVar]] <-
factorLoadingDiamondCIplot(res$intermediate$efas[[rowVar]][[colVar]], factorLoadingDiamondCIplot(res$intermediate$efas[[rowVar]][[colVar]],
colors=colors, colors=colors,
sortAlphabetically=TRUE) + sortAlphabetically=TRUE) +
...@@ -527,11 +527,11 @@ CIM <- function(data, ...@@ -527,11 +527,11 @@ CIM <- function(data,
} else { } else {
grobsList[[rowIndex]][[colIndex]] <- grobsList[[rowIndex]][[colIndex]] <-
res$intermediate$diamondplots[[rowVar]][[colVar]] <- res$intermediate$factorLoadingPlots[[rowVar]][[colVar]] <-
factorLoadingHeatmap( factorLoadingHeatmap(
res$intermediate$efas[[rowVar]][[colVar]], res$intermediate$efas[[rowVar]][[colVar]],
sortAlphabetically=TRUE sortAlphabetically=TRUE
); );
} }
...@@ -556,34 +556,41 @@ CIM <- function(data, ...@@ -556,34 +556,41 @@ CIM <- function(data,
cat0("\n\n"); cat0("\n\n");
} }
grobsList[[rowIndex]][[colIndex]] <- if (n.iter > 1) {
gridExtra::gtable_combine(headerTable,
grobsList[[rowIndex]][[colIndex]],
along=2);
prevWidths <- grobsList[[rowIndex]][[colIndex]]$widths; grobsList[[rowIndex]][[colIndex]] <-
gridExtra::gtable_combine(headerTable,
grobsList[[rowIndex]][[colIndex]],
along=2);
### Add variable names prevWidths <- grobsList[[rowIndex]][[colIndex]]$widths;
titleString <-
sort(c(rowVar, colVar)); ### Add variable names
titleString <- paste0(titleString[1], ' & ', titleString[2]); titleString <-
grobsList[[rowIndex]][[colIndex]] <- sort(c(rowVar, colVar));
gridExtra::gtable_combine(makeHeaderTable(titleString, titleString <- paste0(titleString[1], ' & ', titleString[2]);
colSpan=6), grobsList[[rowIndex]][[colIndex]] <-
grobsList[[rowIndex]][[colIndex]], gridExtra::gtable_combine(
along=2); makeHeaderTable(
titleString,
### Set widths (again, based on colSpan=ncol(res$intermediate$faDfs[[colVar]][[rowVar]]$faDf_rounded)
### https://github.com/baptiste/gridextra/wiki/tableGrob ),
grobsList[[rowIndex]][[colIndex]]$widths <- grobsList[[rowIndex]][[colIndex]],
grid::unit(rep(.95 * (1/ncol(grobsList[[rowIndex]][[colIndex]])), along=2
ncol(grobsList[[rowIndex]][[colIndex]])), );
"npc");
### Set widths (again, based on
### https://github.com/baptiste/gridextra/wiki/tableGrob
grobsList[[rowIndex]][[colIndex]]$widths <-
grid::unit(rep(.95 * (1/ncol(grobsList[[rowIndex]][[colIndex]])),
ncol(grobsList[[rowIndex]][[colIndex]])),
"npc");
}
} }
} }
} }
### Finally, construct content; for diagonal, omega etc; for ### Finally, construct content; for diagonal, omega etc; for
### upper diagonal, diamondPlots; for lower diagnoal, numbers ### upper diagonal, factorLoadingPlots; for lower diagnoal, numbers
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment