[R] Trouble with strwrap function

Uwe Ligges ligges at statistik.tu-dortmund.de
Mon Mar 5 19:45:06 CET 2012



On 05.03.2012 01:49, Aimee Jones wrote:
> Hi all,
>
> I am formatting some graphs and adding text to them. When using the
> strwrap function in the code below, it properly cuts the main title
> into sizeable chunks and pastes the second line below that of the
> first. The subtitle however, is all pasted on the same line, meaning
> that it reads as gibberish in the graphical output. What can I do to
> make sure the subtitle posts in consecutive lines (without using /n )?


This is not supported, but you can easily ask R to insert newline (\n) 
characters.

Uwe Ligges

>
> thank you for your assistance,
> Aimee Jones
>
> par(mfrow=c(1,1))
> plot(out_rk4$time, out_rk4$N2, col="blue", type="l", lwd=3,
> cex.lab=0.75, xlim=c(0,3650), ylim=c(0,5000),xlab="Time(days)",
> ylab="Numbers of Population", main=paste(strwrap("Total Cattle
> population and Infected Aedes and Culex mosquitoes as a function of
> time", width= 60)))
> par(new=TRUE)
> plot(out_rk4$time, out_rk4$I1, col="red", type="l", lwd=3,
> xlim=c(0,3650), ylim=c(0,5000), xlab="", ylab="")
> par(new=TRUE)
> plot(out_rk4$time, out_rk4$I3, col="green", type="l", lwd=3,
> xlim=c(0,3650), ylim=c(0,5000), xlab="", ylab="", cex.sub=0.5,
> sub=paste(strwrap("The peaks in infected Aedes and Culex mosquitoes
> correspond to a fall in cattle population due to a die-off. Infected
> mosquito populations return to 0 when cattle population falls below a
> critical level to maintain the virus in circulation. Births increase
> the cattle population past this critical limit and once again, a mass
> die-off of cattle and spike in infected mosquitoes occurs.", width
> =360)) )
> par(new=FALSE)
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list