Hi Ara,
Ara Kooser wrote:
> I just started in on R today. I am at the point where I am trying
> to distinguish different groups of data (hydrochemical data) in
> biplot. I search and found a post about converting the sample number
> in biplot to a symbol like x or +
>
> "> temp <- matrix(runif(50), nrow=10)
> > temp.pca <- princomp(temp)
> > biplot(temp.pca, xlabs=c("A", "A", "B",
"B", "B", "C", "C", "C",
> "D", "D"))"
>
> When I try this:
> > biplot(pca,xlabs=c("X"))
> Error in dimnames(x) <- list(xlabs, dimnames(x)[[2L]]) :
> length of 'dimnames' [1] not equal to array extent
>
> I guess I am not understanding fully what xlabs is doing and what the
> array extent is.
You need to add as many symbols (i.e. a character vector
with as many elements) as there are rows in your dataset
biplot(temp.pca, xlabs= rep("X", 10), col = c("blue",
"darkgrey"))
should work, similarly to the 10 symbols ("A", "A",
"B", etc.)
you used in your call above.
I was wondering if someone could clarify for me how> to change the sample numbers to a symbol?
>
> Also is there a way to color a group of data (i.e. samples 1-50) in
> biplot?
From the help page of biplot.default, it seems the col argument can
be used only to specify the two colors for the two sets of points
which are drawn on the biplot.
Once you get familiar with R graphics, however, it should be relatively
straightforward to work out your own biplot function.
When looking through the code of biplot.default using
getAnywhere("biplot.default")
you will see places where the col argument is used
(look for col[1L] and col[2L]).
HTH,
Tobias