From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>

Date: Mon 30 May 2005 - 02:15:47 EST

R-help@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 Received on Mon May 30 02:20:50 2005

Date: Mon 30 May 2005 - 02:15:47 EST

Helmut Kudrnovsky wrote:

> 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 think points should be a matrix rather than a list or data.frame, hence the code above won't work. Instead:

plot(points[,"PC1"], points[,"PC2"], type="n")

> - 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)
*

Hmm, what is pca ???

lab <- rownames(points)

text(points[,"PC1"], points[,"PC2"], labels=lab)

works for me.

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

*> s1-s10
*

Quite probably you lab was a *factor* ...

> 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?
*

We cannot say what you did wrong when constructing your plot, but we know that your descibtion above is wrong, because it does not even work to generate the empty plot the way ...

Please read the posting guide and rethink at least one time whether the code you are giving us is reproducible. Your code was not.

Uwe Ligges

> 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
**>
**> ______________________________________________
**> R-help@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
*

R-help@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 Received on Mon May 30 02:20:50 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:32:15 EST
*