% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/screeplot.pcss.core.R
\name{screeplot.pcss.core}
\alias{screeplot.pcss.core}
\title{Plot Eigen values as a Scree Plot from \code{pcss.core} Output}
\usage{
\method{screeplot}{pcss.core}(x, ndim = NULL, show.values = TRUE, ...)
}
\arguments{
\item{x}{An object of class \code{pcss.core}.}

\item{ndim}{The number of eigen values to be plotted in the scree plot.}

\item{show.values}{If \code{TRUE}, the eigen values are shown in the plot as
annotation labels. Default is \code{TRUE}.}

\item{...}{Unused.}
}
\value{
The scree plot as a \code{ggplot} object.
}
\description{
\code{screeplot.pcss.core} generates a scree plot of eigen values from the
output of \code{pcss.core}.
}
\examples{

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Prepare example data
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

if (requireNamespace('EvaluateCore', quietly = TRUE) &
    requireNamespace("factoextra", quietly = TRUE)) {

  # Get data from EvaluateCore

  data("cassava_EC", package = "EvaluateCore")
  data = cbind(Genotypes = rownames(cassava_EC), cassava_EC)
  quant <- c("NMSR", "TTRN", "TFWSR", "TTRW", "TFWSS", "TTSW", "TTPW", "AVPW",
             "ARSR", "SRDM")
  qual <- c("CUAL", "LNGS", "PTLC", "DSTA", "LFRT", "LBTEF", "CBTR", "NMLB",
            "ANGB", "CUAL9M", "LVC9M", "TNPR9M", "PL9M", "STRP", "STRC",
            "PSTR")
  rownames(data) <- NULL

  # Convert qualitative data columns to factor
  data[, qual] <- lapply(data[, qual], as.factor)


  library(FactoMineR)
  suppressPackageStartupMessages(library(factoextra))

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# With quantitative data
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  out1 <- pcss.core(data = data, names = "Genotypes",
                    quantitative = quant,
                    qualitative = NULL, eigen.threshold = NULL, size = 0.2,
                    var.threshold = 0.75)

  # Plot scree plot
  screeplot(x = out1)

  # Plot biplot with factoextra
  fviz_screeplot(out1$raw.out)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Get core sets with PCSS (qualitative data)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  out2 <- pcss.core(data = data, names = "Genotypes", quantitative = NULL,
                    qualitative = qual, eigen.threshold = NULL,
                    size = 0.2, var.threshold = 0.75)

  # Plot scree plot
  screeplot(x = out2)

  # Plot biplot with factoextra
  fviz_screeplot(out2$raw.out)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Get core sets with PCSS (quantitative and qualitative data)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  out3 <- pcss.core(data = data, names = "Genotypes",
                    quantitative = quant,
                    qualitative = qual, eigen.threshold = NULL)

  # Plot scree plot
  screeplot(x = out3)

  # Plot biplot with factoextra
  fviz_screeplot(out3$raw.out)

} else {
  message('Packages "EvaluateCore" and "factoextra" are required to run these examples.')
}

}
\seealso{
\code{\link[rpcss]{pcss.core}},
  \code{\link[factoextra]{fviz_screeplot}}
}
