Skip to content

Commit

Permalink
fix for #26
Browse files Browse the repository at this point in the history
  • Loading branch information
kassambara committed Feb 6, 2017
1 parent a57b53d commit e635ccd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 9 additions & 4 deletions R/fviz.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ NULL
#' ex: 5, then the top 5 individuals/variables with the highest cos2 are
#' drawn. \item contrib: if contrib > 1, ex: 5, then the top 5
#' individuals/variables with the highest contrib are drawn }
#' @param a ggplot. If not NULL, points are added to an existing plot.
#' @inheritParams ggpubr::ggpar
#' @param ... Arguments to be passed to the functions ggpubr::ggscatter() & ggpubr::ggpar().
#'
Expand Down Expand Up @@ -113,6 +114,7 @@ fviz <- function(X, element, axes = c(1, 2), geom = "auto",
select = list(name = NULL, cos2 = NULL, contrib = NULL),
title = NULL, axes.linetype = "dashed",
repel = FALSE, col.circle ="grey70", ggtheme = theme_minimal(),
ggp = NULL,
...)
{

Expand Down Expand Up @@ -189,14 +191,17 @@ fviz <- function(X, element, axes = c(1, 2), geom = "auto",
if(lab[[element]] & "text" %in% geom & !hide[[element]]) label <- "name"

p <- ggplot()
if(hide[[element]]) p <-ggplot()+geom_blank(data = df, aes_string("x","y"))
if(hide[[element]]) {
if(is.null(ggp)) p <-ggplot()+geom_blank(data = df, aes_string("x","y"))
else p <- ggp
}
else p <- ggpubr::ggscatter(data = df, x = "x", y = "y",
color = color, alpha = alpha, shape = pointshape,
point = point, size = pointsize, mean.point = mean.point,
label = label, font.label = labelsize*3, repel = repel,
ellipse = addEllipses, ellipse.type = ellipse.type,
ellipse.alpha = ellipse.alpha, ellipse.level = ellipse.level,
main = title, ggtheme = ggtheme, ...)
main = title, ggtheme = ggtheme, ggp = ggp, ...)
if(alpha %in% c("cos2","contrib", "coord", "x", "y"))
p <- p + scale_alpha(limits = range(df.all[, alpha]))
if(!is.null(gradient.cols) & color %in% c("cos2","contrib", "coord", "x", "y"))
Expand Down Expand Up @@ -308,8 +313,8 @@ fviz <- function(X, element, axes = c(1, 2), geom = "auto",
if(element == "ind" & inherits(X, c('PCA', "MCA", "MFA", "FAMD")) & !hide$ind.sup)
res <- list(name = "ind.sup", addlabel = (lab$ind.sup & "text" %in% geom))
# Supplementary quantitative variables
else if(element == "var" & inherits(X, 'PCA') & !hide$quanti)
res <- list(name = "quanti", addlabel = (lab$quanti & "text" %in% geom))
else if(element == "var" & inherits(X, 'PCA') & !hide$quanti.sup)
res <- list(name = "quanti", addlabel = (lab$quanti.sup & "text" %in% geom))
else if(element == "mca.cor" & inherits(X, 'MCA') & !hide$quanti)
res <- list(name = c("quanti.sup", "quali.sup$eta2"), addlabel = (lab$quanti & "text" %in% geom))
else if(element %in% "var" & inherits(X, 'MCA') & !hide$quali.sup)
Expand Down
4 changes: 3 additions & 1 deletion man/fviz.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e635ccd

Please sign in to comment.