[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 13:59:23 CET 2005


Petr Pikal wrote:
> Hi
> 
> did you tried something like
> 
> write.table( tab, "file.txt", sep="\t", row.names=F)
> 
> which writes to tab separated file?
> 

Petr thanks, but I do not want a tab delimited file. I need spaces
between columns.

> 
> On 21 Nov 2005 at 11:56, Gregor Gorjanc wrote:
> 
> Date sent:      	Mon, 21 Nov 2005 11:56:48 +0100
> From:           	Gregor Gorjanc <gregor.gorjanc at bfro.uni-lj.si>
> Organization:   	University of Ljubljana
> To:             	r-help at r-project.org
> Subject:        	[R] Is there anything like a write.fwf() or possibility to print a
> 	data.frame without rownames?
> Send reply to:  	gregor.gorjanc at bfro.uni-lj.si
> 	<mailto:r-help-request at stat.math.ethz.ch?subject=unsubscribe>
> 	<mailto:r-help-request at stat.math.ethz.ch?subject=subscribe>
> 
>>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