[Rd] stats::screeplot suggestion
Michael Friendly
|r|end|y @end|ng |rom yorku@c@
Thu Jun 18 18:43:30 CEST 2020
Hi
Here is a suggestion/request for stats::screeplot
* Please allow to change xlab and ylab. The attached file does that, and maintains current behavior. Reason: strictly speaking, ylab should be "Variance" (singular). It would also be better to have an explicit label for the X axis: "Component"
In the would-be-nice-if category, I suggest addition of a type="cumulative" chart, a line graph of cumulative % of variance, labeled "% Variance" by default.
-Michael
----- screeplot.default.R ---------
screeplot.default <- function (x, npcs = min(10, length(x$sdev)),
type = c("barplot", "lines"),
xlab = "",
ylab = "Variances",
main = deparse(substitute(x)), ...)
{
main
type <- match.arg(type)
pcs <- x$sdev^2
xp <- seq_len(npcs)
dev.hold()
on.exit(dev.flush())
if (type == "barplot")
barplot(pcs[xp], names.arg = names(pcs[xp]), main = main,
ylab = ylab, ...)
else {
plot(xp, pcs[xp], type = "b", axes = FALSE, main = main,
xlab = xlab, ylab = ylab, ...)
axis(2)
axis(1, at = xp, labels = names(pcs[xp]))
}
invisible()
}
----------------------------------------
--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, ASA Statistical Graphics Section
York University Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele Street Web: http://www.datavis.ca | @datavisFriendly
Toronto, ONT M3J 1P3 CANADA
More information about the R-devel
mailing list