[R] question about "srt" argument in text() plotting function

Carl Witthoft carl at witthoft.com
Fri Feb 25 22:28:07 CET 2011



Just wondering: it appears that "srt" does not accept a vector of 
values, just a single  value.  I ended up using tapply() as the 
following code snippet shows, so it's not a major problem.  I was justa 
little surprised that this argument (srt) differs from things like 
"labels,"  "lty,"  "col,"  and so on, all of which accept (and recycle 
as needed IIRC) vectors.

Carl

******* code follows  *******

dialang<-seq(pi/3,-pi*3/2,by=-pi/6)
         d2<-as.character(seq(1,12)) # or roll your own hour tags
         plot(c(-1.2,1.2),c(-1.2,1.2),t='n',xlab='',ylab='', 
xaxt='n',yaxt='n' )
#trying a rotation w/ srt()
         # srt apparently can't handle a vector
         invisible(sapply(seq(1,12),FUN=function(x) 
text(cos(dialang[x]),sin(dialang[x]),labels=d2[x],srt=-x*30)))



More information about the R-help mailing list