Re: [R] Aligning ragged text columns

From: hadley wickham <>
Date: Wed 19 Jul 2006 - 20:53:59 EST

> I find that things line up better in data.frames

That's a good idea, although I was hoping there would be something in R to do it for me.

I have ended up with:

	fwidth <- max(nchar(x[,1]))
	descs <- strwrap(x[,2], width=width - fwidth - 5, simplify=FALSE)
output <-, mapply(function(name, desc) {
	cbind(c(name, rep("", length=length(desc)-1)), desc)
}, x[,1], descs))         

        cat(paste(format(output[,1]), output[,2], collapse="\n"), "\n")


Hadley mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Wed Jul 19 20:57:41 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 19 Jul 2006 - 22:16:59 EST.

Mailing list information is available at Please read the posting guide before posting to the list.