[R] graphics ignore tabs in text

Marc Schwartz MSchwartz at mn.rr.com
Tue Oct 31 16:56:56 CET 2006


On Tue, 2006-10-31 at 09:13 -0500, Liaw, Andy wrote:
> Dear R-help,
> 
> I seem to recall that I can use "\t" to get tab in a string on a
> graphics device, but it doesn't seem to work.  Try:
> 
> lab <- "a\tb\tc"
> cat(lab, "\n")       # works in the console output
> plot(1:5, main=lab)  # no tabs in the title
> text(3, 3, lab)      # no tabs in the text
> 
> I get the same result both in the windows() and pdf() devices.  Any
> ideas?
> 
> This is R-patched Windows binary just downloaded from CRAN.
> R version 2.4.0 Patched (2006-10-29 r39744)
> 
> Best,
> Andy

Andy, 

I don't believe that tab expansion works in plots, though I will stand
to be corrected on that.

Using the X11() device on FC5 (which I recreated using png() and
attached here), you can clearly see the dashed boxes where the tab
character (non-printable 0x9) is being drawn. However, it is one
character, not expanded as is the case in a textual console/GUI.

What are you trying to accomplish? 

Perhaps there is a better way (ie. to do column alignments, etc.) such
as textplot() in the gplots package.

HTH,

Marc Schwartz

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Rplot001.png
Type: image/png
Size: 3141 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20061031/4a520ff7/attachment.png 


More information about the R-help mailing list