[R] Suppressing final spaces in data.frame printouts
Stavros Macrakis
macrakis at alum.mit.edu
Wed Nov 11 22:56:48 CET 2009
When printing data.frames, R aligns columns by padding with spaces.
For example,
print(data.frame(x=c('a','bb','ccc')),right=FALSE)
x
1 a |------------------ vertical bar shows end of line
2 bb |------------------ vertical bar shows end of line
3 ccc|------------------ vertical bar shows end of line
Is there some way to suppress the padding for the final column? I
often have data frames which contain a handful of long strings in the
final column which, when printed out, cause wraparound on all the
rows, even those not containing long strings, something like this:
print(data.frame(q=1:3,x=c('a','bb','this is a very long string')),right=FALSE)
q x |
|
1 1 a |
|
2 2 bb |
|
3 3 this is a very l|
ong string|
where I'd rather have
print(data.frame(q=1:3,x=c('a','bb','this is a very long string')),right=FALSE)
q x|
1 1 a|
2 2 bb|
3 3 this is a very l|
ong string|
I could of course write my own print function for this, but was
wondering if there was a standard way of doing it. If not in R,
perhaps there is some way to have ESS delete the final spaces?
Thanks,
-s
More information about the R-help
mailing list