[Rd] Wishlist: write.delim()

Douglas Grove dgrove at fhcrc.org
Fri Sep 9 17:02:22 CEST 2005


On Fri, 9 Sep 2005, Martin Maechler wrote:

> >>>>> "Douglas" == Douglas Grove <dgrove at fhcrc.org>
> >>>>>     on Thu, 8 Sep 2005 15:33:02 -0700 (PDT) writes:
> 
>     Douglas> Hi,
>     Douglas> It would be great if someone would add write.delim() as an
>     Douglas> adjunct to write.table(), just as with write.csv().
> 
>     Douglas> I store a lot of data in tab-delimited files and can read
>     Douglas> it in easily with:  read.delim("text.txt", as.is=TRUE)
>     Douglas> and would love to be able to write it out as easily when
>     Douglas> I create these files.
> 
>     Douglas> The obvious setting needed for write.delim() is sep = "\t",
>     Douglas> but in addition I would request the setting row.names = FALSE
> 
>     Douglas> i.e. 
> 
>     Douglas> write.delim(x, file) = write.table(x, file, sep = "\t", row.names=FALSE)
> 
> i.e.,
>    write.delim <- function(x, file, ...) 
> 		    write.table(x, file, sep = "\t", row.names=FALSE, ...)
> 
> So, why don't you just add that one line to your .Rprofile ?
 
I would love to do this, but I have to distribute code to people who
are not only R illiterate, but also fairly computer illiterate as well.
So for simplicity I can't use a lot of little convenience functions 
that I'd prefer to use.  


> In general, I don't think that it's worth to introduce a whole
> new function just because of some frequent argument use of an
> already existing function  {{and I have wondered if it was worth
> to provide write.csv() at all - although, there the difference to default
> write.table() is quite a bit larger}}

I agree that it's not a good idea in general.  I suggested this since
there's plenty of precedent in the read and write table functions. 
On the "read" sinde there's read.csv, read.csv2, read.delim and read.delim2
and on the 'write" side there are write.csv and write.csv2.  So it seems
obvious (from a simplistic point of view) to balance these out and offer
write.delim and write.delim2. 

Probably one would want to use the same 'qmethod' setting too, as 
write.csv and write.csv2 use.  So that would bring the number of changed
arguments to 3, the same as write.csv has...

Doug



More information about the R-devel mailing list