From 61f1da1cf05f26324bd19d42a02c55ad5c37089d Mon Sep 17 00:00:00 2001 From: wesley4546 <56905659+wesley4546@users.noreply.github.com> Date: Thu, 16 Sep 2021 01:21:02 -0400 Subject: [PATCH] added roxygen & fixed ggbiplot `library()` calls --- DESCRIPTION | 6 ++- NAMESPACE | 6 +++ R/ggbiplot.r | 13 ++++--- ggbiplot.Rproj | 1 + man/ggbiplot.Rd | 95 ++++++++++++++++++++++++---------------------- man/ggscreeplot.Rd | 23 +++++------ 6 files changed, 80 insertions(+), 64 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f90b3a7..bbfa71a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,9 +9,13 @@ Description: A ggplot2 based biplot. It provides a drop-in replacement for biplot.princomp(). It implements a biplot and scree plot using ggplot2. Depends: - ggplot2, plyr, scales, grid + ggplot2, + plyr, + scales, + grid License: GPL-2 URL: http://github.com/vqv/ggbiplot Collate: 'ggbiplot.r' 'ggscreeplot.r' +RoxygenNote: 7.1.1 diff --git a/NAMESPACE b/NAMESPACE index eef88a6..b354f11 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,2 +1,8 @@ +# Generated by roxygen2: do not edit by hand + export(ggbiplot) export(ggscreeplot) +import(ggplot2) +import(grid) +import(plyr) +import(scales) diff --git a/R/ggbiplot.r b/R/ggbiplot.r index e0e06e6..abb473d 100644 --- a/R/ggbiplot.r +++ b/R/ggbiplot.r @@ -37,6 +37,14 @@ #' @param varname.size size of the text for variable names #' @param varname.adjust adjustment factor the placement of the variable names, >= 1 means farther from the arrow #' @param varname.abbrev whether or not to abbreviate the variable names +#' @param circle.prob (in progress) +#' @param ... (in progress) +#' +#' +#' @import ggplot2 +#' @import plyr +#' @import scales +#' @import grid #' #' @return a ggplot2 plot #' @export @@ -54,11 +62,6 @@ ggbiplot <- function(pcobj, choices = 1:2, scale = 1, pc.biplot = TRUE, varname.size = 3, varname.adjust = 1.5, varname.abbrev = FALSE, ...) { - library(ggplot2) - library(plyr) - library(scales) - library(grid) - stopifnot(length(choices) == 2) # Recover the SVD diff --git a/ggbiplot.Rproj b/ggbiplot.Rproj index dead601..553ae74 100644 --- a/ggbiplot.Rproj +++ b/ggbiplot.Rproj @@ -15,3 +15,4 @@ LaTeX: XeLaTeX BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace,vignette diff --git a/man/ggbiplot.Rd b/man/ggbiplot.Rd index 82e2070..05a1219 100644 --- a/man/ggbiplot.Rd +++ b/man/ggbiplot.Rd @@ -1,74 +1,79 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ggbiplot.r \name{ggbiplot} \alias{ggbiplot} \title{Biplot for Principal Components using ggplot2} \usage{ - ggbiplot(pcobj, choices = 1:2, scale = 1, pc.biplot = - TRUE, obs.scale = 1 - scale, var.scale = scale, groups = - NULL, ellipse = FALSE, ellipse.prob = 0.68, labels = - NULL, labels.size = 3, alpha = 1, var.axes = TRUE, circle - = FALSE, circle.prob = 0.69, varname.size = 3, - varname.adjust = 1.5, varname.abbrev = FALSE, ...) +ggbiplot( + pcobj, + choices = 1:2, + scale = 1, + pc.biplot = TRUE, + obs.scale = 1 - scale, + var.scale = scale, + groups = NULL, + ellipse = FALSE, + ellipse.prob = 0.68, + labels = NULL, + labels.size = 3, + alpha = 1, + var.axes = TRUE, + circle = FALSE, + circle.prob = 0.69, + varname.size = 3, + varname.adjust = 1.5, + varname.abbrev = FALSE, + ... +) } \arguments{ - \item{pcobj}{an object returned by prcomp() or - princomp()} +\item{pcobj}{an object returned by prcomp() or princomp()} - \item{choices}{which PCs to plot} +\item{choices}{which PCs to plot} - \item{scale}{covariance biplot (scale = 1), form biplot - (scale = 0). When scale = 1, the inner product between - the variables approximates the covariance and the - distance between the points approximates the Mahalanobis - distance.} +\item{scale}{covariance biplot (scale = 1), form biplot (scale = 0). When scale = 1, the inner product between the variables approximates the covariance and the distance between the points approximates the Mahalanobis distance.} - \item{obs.scale}{scale factor to apply to observations} +\item{pc.biplot}{for compatibility with biplot.princomp()} - \item{var.scale}{scale factor to apply to variables} +\item{obs.scale}{scale factor to apply to observations} - \item{pc.biplot}{for compatibility with - biplot.princomp()} +\item{var.scale}{scale factor to apply to variables} - \item{groups}{optional factor variable indicating the - groups that the observations belong to. If provided the - points will be colored according to groups} +\item{groups}{optional factor variable indicating the groups that the observations belong to. If provided the points will be colored according to groups} - \item{ellipse}{draw a normal data ellipse for each - group?} +\item{ellipse}{draw a normal data ellipse for each group?} - \item{ellipse.prob}{size of the ellipse in Normal - probability} +\item{ellipse.prob}{size of the ellipse in Normal probability} - \item{labels}{optional vector of labels for the - observations} +\item{labels}{optional vector of labels for the observations} - \item{labels.size}{size of the text used for the labels} +\item{labels.size}{size of the text used for the labels} - \item{alpha}{alpha transparency value for the points (0 = - TRUEransparent, 1 = opaque)} +\item{alpha}{alpha transparency value for the points (0 = transparent, 1 = opaque)} - \item{circle}{draw a correlation circle? (only applies - when prcomp was called with scale = TRUE and when - var.scale = 1)} +\item{var.axes}{draw arrows for the variables?} - \item{var.axes}{draw arrows for the variables?} +\item{circle}{draw a correlation circle? (only applies when prcomp was called with scale = TRUE and when var.scale = 1)} - \item{varname.size}{size of the text for variable names} +\item{circle.prob}{(in progress)} - \item{varname.adjust}{adjustment factor the placement of - the variable names, >= 1 means farther from the arrow} +\item{varname.size}{size of the text for variable names} - \item{varname.abbrev}{whether or not to abbreviate the - variable names} +\item{varname.adjust}{adjustment factor the placement of the variable names, >= 1 means farther from the arrow} + +\item{varname.abbrev}{whether or not to abbreviate the variable names} + +\item{...}{(in progress)} } \value{ - a ggplot2 plot +a ggplot2 plot } \description{ - Biplot for Principal Components using ggplot2 +Biplot for Principal Components using ggplot2 } \examples{ -data(wine) -wine.pca <- prcomp(wine, scale. = TRUE) -print(ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups = wine.class, ellipse = TRUE, circle = TRUE)) -} + data(wine) + wine.pca <- prcomp(wine, scale. = TRUE) + print(ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups = wine.class, ellipse = TRUE, circle = TRUE)) +} diff --git a/man/ggscreeplot.Rd b/man/ggscreeplot.Rd index 1e7ce96..452b67d 100644 --- a/man/ggscreeplot.Rd +++ b/man/ggscreeplot.Rd @@ -1,25 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ggscreeplot.r \name{ggscreeplot} \alias{ggscreeplot} \title{Screeplot for Principal Components} \usage{ - ggscreeplot(pcobj, type = c("pev", "cev")) +ggscreeplot(pcobj, type = c("pev", "cev")) } \arguments{ - \item{pcobj}{an object returned by prcomp() or - princomp()} +\item{pcobj}{an object returned by prcomp() or princomp()} - \item{type}{the type of scree plot. 'pev' corresponds - proportion of explained variance, i.e. the eigenvalues - divided by the trace. 'cev' corresponds to the cumulative - proportion of explained variance, i.e. the partial sum of - the first k eigenvalues divided by the trace.} +\item{type}{the type of scree plot. 'pev' corresponds proportion of explained variance, i.e. the eigenvalues divided by the trace. 'cev' corresponds to the cumulative proportion of explained variance, i.e. the partial sum of the first k eigenvalues divided by the trace.} } \description{ - Screeplot for Principal Components +Screeplot for Principal Components } \examples{ -data(wine) -wine.pca <- prcomp(wine, scale. = TRUE) -print(ggscreeplot(wine.pca)) -} + data(wine) + wine.pca <- prcomp(wine, scale. = TRUE) + print(ggscreeplot(wine.pca)) +}