Skip to content

Commit

Permalink
Fix for Issue #120
Browse files Browse the repository at this point in the history
  • Loading branch information
Max-Bladen committed Mar 8, 2022
1 parent 8fc6d96 commit f2344f2
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions R/plotLoadings.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ plotLoadings.mixo_pls <-
if (length(block) == 1 & !is.null(name.var))
name.var = list(name.var = name.var)

contrib.df <- list()

for (i in 1 : length(block))
{
res = get.loadings.ndisplay(object = object, comp = comp, block = block[i], name.var = name.var[[i]], name.var.complete = name.var.complete, ndisplay = ndisplay)
Expand Down Expand Up @@ -204,8 +206,12 @@ plotLoadings.mixo_pls <-
} else if (length(block) > 1 & !missing(subtitle)) {
title(paste(subtitle[i]), line=0, cex.main = size.subtitle)
}

contrib.df <- c(contrib.df, list(df))
}

names(contrib.df) <- block

if (length(block) > 1 & !is.null(title))
title(title, outer=TRUE, line = -2, cex.main = size.title)

Expand All @@ -215,7 +221,7 @@ plotLoadings.mixo_pls <-
par(mar = omar) #reset mar

# return the contribution matrix
return(invisible(df))
return(invisible(contrib.df))
}

#' @rdname plotLoadings
Expand Down Expand Up @@ -391,6 +397,9 @@ plotLoadings.mixo_plsda <-
if (length(block) == 1 & !is.null(name.var))
name.var = list(name.var = name.var)


contrib.df <- list()

for (i in 1 : length(block))
{
res = get.loadings.ndisplay(object = object, comp = comp, block = block[i], name.var = name.var[[i]], name.var.complete = name.var.complete, ndisplay = ndisplay)
Expand Down Expand Up @@ -457,9 +466,14 @@ plotLoadings.mixo_plsda <-
title = paste(legend.title),
cex = size.legend)
}

contrib.df <- c(contrib.df, list(df))
} # end if plot
}

names(contrib.df) <- block


if(plot) # overall title and reset par if needed
{
# legend
Expand All @@ -473,7 +487,7 @@ plotLoadings.mixo_plsda <-
}

# return the contribution matrix
return(invisible(df))
return(invisible(contrib.df)) # df
}# end contrib missing
}

Expand Down Expand Up @@ -1253,6 +1267,7 @@ get.contrib.df <- function(Y,
method.group[[k]] = tapply(X[, k], Y, method, na.rm=TRUE) #method is either mean or median
# determine which group has the highest mean/median
which.contrib[k, 1:nlevels(Y)] = (method.group[[k]]) == get(contrib)((method.group[[k]]), na.rm=TRUE) # contrib is either min or max

}

# we also add an output column indicating the group that is max
Expand Down

0 comments on commit f2344f2

Please sign in to comment.