Message-ID: <D7333E2B-FB82-4CCE-A620-E8967075B343@gmail.com>
Date: 2009-04-15T00:34:38Z
From: Brendan Morse
Subject: Controlling widths in write.fwf()
In-Reply-To: <2018A7D503F84748AECB8E75D42841170164616F@uspalex04.epri.com>
Hi Aparna, you could always use the write.table function and set
sep="". This will put all of your data into a sort of "fixed-width"
column depending on what you specify to separate the values. See basic
example below:
x<-matrix(nrow=2, ncol=2, c(1,2,3,4))
write.table(x, "/Users/morse07/Desktop/x.txt", sep="",
col.names=FALSE, row.names=FALSE)
Note that any spaces you insert between the "" after the sep command
will insert 1 fixed-width column per space in your file.
Hope that helps,
Brendan
On Apr 14, 2009, at 7:28 PM, Vemuri, Aparna wrote:
> Is there a way to handle the widths of values being written to a file
> using wrtite.fwf() ?
>
> For example, I used read.fwf(file, width.vector) to read a file. After
> making the necessary data manipulation, I want to write the data to a
> new file in the same width.vector format. Is there a way to specify
> this?
>
> Thanks in Advance
> Aparna
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.