Re: [R] text on some lines

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed 27 Jul 2005 - 00:24:18 EST

On Tue, 26 Jul 2005, Uwe Ligges wrote:

> Navarre Sabine wrote:

>> I would like to write text on 2 lines for example.
>> For example, if you have a long sentence and you want to cut it
> at the 45 caracter and put the continuation underneath!
>> Is it possible?
>
> Do you mean for output to console / in plots?
> Simply insert a "\n" (newline), for example.

And strwrap() will help you insert it in the right place, e.g.

> x <- "For example, if you have a long sentence and you want to cut it at the 45 caracter and put the continuation underneath!"
> strwrap(x, 45)

[1] "For example, if you have a long sentence"
[2] "and you want to cut it at the 45 caracter"
[3] "and put the continuation underneath!"

> paste(strwrap(x, 45), collapse="\n")

[1] "For example, if you have a long sentence\nand you want to cut it at the 45 caracter\nand put the continuation underneath!"

the latter for use when plotting.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
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 Wed Jul 27 00:31:51 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:34:01 EST