[R] "text"-function: adding text in an x,y-plot

Helmut Kudrnovsky hellik at web.de
Sun May 29 18:07:42 CEST 2005


Hello R-friends,

i have a question to the "text"-function.

a little test-dataset for better understanding:

-the dataset was imported with read.table(....,header=TRUE)
s1-s10 are the samplenames

     var1 var2 var3
s1     1    1    2
s2     2    3    1
s3     2    2    3
s4     5    4    3
s5     4    2    3
s6     6    3    2
s7     8    5    4
s8     7    2    1
s9     9    3    2
s10    8    6    4

-then i´ve performed a pincipal component analysis with prcomp

-for displaying the result in a x,y-graph i transformed out.pca$x into the 
dataframe points
  points <- out.pca$x
 > points
            PC1         PC2        PC3
s1  -4.7055777 -0.14781544 -0.3683602
s2  -3.1854599  0.19661476  1.5212455
s3  -3.2687980  0.78193513 -0.6352458
s4   0.2278948  1.00061498  0.2164108
s5  -1.4382847  0.02500633 -0.9114340
s6   0.6216283 -0.68606440  0.2071083
s7   3.4951878  1.17343675 -0.3266629
s8   1.0153619 -2.37274378  0.1978058
s9   3.3673983 -1.82145761 -0.2071739
s10  3.8706492  1.85047328  0.3063065

- with plot(points$PC1, points$PC2, type="n") i start a graph without 
displaying anything at the x,y-coordinates

- i want now to display the samplenames at the right x,y-coordinate;  i 
generated a dataframe called lab with the samplenames

 > lab
     V1
1   s1
2   s2
3   s3
4   s4
5   s5
6   s6
7   s7
8   s8
9   s9
10 s10

- i´ve studied the "text"-helppage and so i tried the following:

text(pca$PC1, pca$PC2, labels=lab)

- in the plot there is now c(1,3,4,5,6,7,8,9,10,2) displayed instead of s1-s10

is out there any idea what i'am doing wrong? is there maybe another way of 
displaying the samplenames at the right x,y-coordinate?

greetings from the sunny tirol with thanks in advance
helli

platform i386-pc-mingw32
arch     i386
os       mingw32 - win xp
system   i386, mingw32
status
major    2
minor    1.0
year     2005
month    04
day      18
language R




More information about the R-help mailing list