Learn R Programming

svdvis (version 0.1)

svd.scree: Scree plot

Description

Creates a scree plot, where percentages of variance explained (PVE) by singular vectors are plotted. Additional customizations can be done by adding ggplot2 functions to the output.

Usage

svd.scree(svd.obj, subr = NULL, maintitle = "Scree Plot", axis.title.x = "Singular Vectors", axis.title.y = "Percent Variance Explained")

Arguments

svd.obj
A list, resulted from applying svd to a dataset, with u, d, and v corresponding to left singular vector, singular values, and right singular vectors, respectively. Alternatively, supply a vector of singular values, d.
subr
An optional positive integer to display PVE corresponding to the first subr singular values.
maintitle
A figure title (by default, "Scree Plot").
axis.title.x
A title for x axis (by default, "Singular Vectors").
axis.title.y
A title for y axis (by default, "Percent Variance Explained").

Value

svd.scree creates and draws a figure, which is a ggplot2 when subr=NULL or a gtable object when subr is specified.

Examples

Run this code
set.seed(1234)
dat = matrix(rnorm(1000), 100, 10)
svd.obj = svd(dat)
colnames(svd.obj$v) = paste0("V",1:10)
svd.scree(svd.obj)

Run the code above in your browser using DataLab