[R] Is there anything like a write.fwf() or possibility to print a data.frame without rownames?

Gregor Gorjanc gregor.gorjanc at bfro.uni-lj.si
Mon Nov 21 11:56:48 CET 2005


Dear R users,

R has read.fwf() function, however I would need write.fwf. I know other
write.* functions, but I need fixed width format of data, which I would
like to export from R. I tried to use:

- write.table, but I can not control alignment of columns

- write.matrix from MASS, but columns are to wide

I came to this option, which is very neat:

# tmp is data.frame

sink(file = file)
print(tmp)
sink()

This works very nice, but I would like to get rid of rownames, which
are always printed.

Another not so important issue is width of printed columns. I presume
this is determined by max(length column name, max(length of "values" in
a column)) but sometimes it would be usefull to control width of columns
also.

Can someone help me with this issue?

-- 
Lep pozdrav / With regards,
    Gregor Gorjanc

----------------------------------------------------------------------
University of Ljubljana     PhD student
Biotechnical Faculty
Zootechnical Department     URI: http://www.bfro.uni-lj.si/MR/ggorjan
Groblje 3                   mail: gregor.gorjanc <at> bfro.uni-lj.si

SI-1230 Domzale             tel: +386 (0)1 72 17 861
Slovenia, Europe            fax: +386 (0)1 72 17 888

----------------------------------------------------------------------
"One must learn by doing the thing; for though you think you know it,
 you have no certainty until you try." Sophocles ~ 450 B.C.




More information about the R-help mailing list