[R] How does biplot.princomp scale its axes?

Gabor Grothendieck ggrothendieck at gmail.com
Tue Aug 1 00:26:25 CEST 2006


Its easiest to just check the source.  biplot is a generic which calls
biplot.princomp which calls biplot.default which in turn calls plot so
try this and examine the source:

stats:::biplot.default


On 7/31/06, Patrick Connolly <p_connolly at ihug.co.nz> wrote:
> I'm attempting to modify how biplot draws its red vectors (among other
> things).  This is how I've started:
>
>
> Biplot <- function(xx, comps = c(1, 2), cex = c(.6, .4))
> {
>  ## Purpose: Makes a biplot with princomp() object to not show arrows
>  ## ----------------------------------------------------------------------
>  ## Arguments: xx is an object made using princomp()
>  ## ----------------------------------------------------------------------
> scores <- xx$scores[, paste("Comp", comps, sep = ".")]
> loadings <- xx$loadings[, paste("Comp", comps, sep = ".")]
> plot(range(scores), range(scores), xlab = "", ylab = "", xaxt = "n",
>           yaxt = "n", pch = " ")
> text(scores[,1], scores[,2], rownames(scores), cex = cex[1])
> axis(2)
> axis(1)
> }
>
> I can make part of a biplot using that function with the USArrests data:
> Biplot(princomp(USArrests, cor = TRUE), c(1,2), cex = c(.6, .4))
>
> Compare that with what we get using biplot.princomp:
> biplot(princomp(USArrests, cor = TRUE), c(1,2), cex = c(.6, .4))
>
> It seems to me that the y-values are the same in both plots, but some
> sort of scaling on the x-axis is happening.  Something similar seems
> to happen with the loadings as well.
>
> I notice in the documentation for biplot, mention is made of "... many
> variations on biplots".  Would I be doing something inexcusable if I
> ignored the differences I've noticed here?
>
> TIA
>
> --
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>   ___    Patrick Connolly
>  {~._.~}                         Great minds discuss ideas
>  _( Y )_                        Middle minds discuss events
> (:_~*~_:)                        Small minds discuss people
>  (_)-(_)                                   ..... Anon
>
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list