From hadley at rice.edu  Tue Oct 18 22:36:48 2011
From: hadley at rice.edu (Hadley Wickham)
Date: Tue, 18 Oct 2011 15:36:48 -0500
Subject: [Rd] readRDS and saveRDS
In-Reply-To: <CANz9Z_JCrVEbjHqpc=4mQD+Ce=XZTA6NL2ktSpB4KZtbRdELyA@mail.gmail.com>
References: <CABdHhvFEpU2zjcV+_Xd_vzrcM__VZ2PMSUgjKCHGYm38Xh+W2w@mail.gmail.com>
	<4E9DAA89.7050601@gmail.com>
	<CANz9Z_JCrVEbjHqpc=4mQD+Ce=XZTA6NL2ktSpB4KZtbRdELyA@mail.gmail.com>
Message-ID: <CABdHhvFJyO2eesS+sbGV40YHuLg95ny5r2Yeu8uGW28yWM7s4Q@mail.gmail.com>

>> Ending names in .foo is a bad idea because of the S3 naming conventions, so
>> I think this is unlikely. ?But you can always create an alias yourself...
>
> I always thought that S3 was part of the reason for read.ext write.ext. In:
>
> "/path/file.ext"
>
> the "class" of the file is "ext". ?I kind of like the idea of taking
> this farther, generic functions read/write dispatch to the appropriate
> method depending on the class of the file. ?Generally, only read/write
> would be used, specifying the specific method as needed. ?read.rda and
> write.rda could replace load/save where: dat <- read.rda() would
> create an environment, dat rather than simply loading them into the
> global environment.
>
> Though this is more of a hypothetical situation than a suggestion for change.

That makes me think of a generic read that would dispatch not on the
class of the first argument (which would always be a string), but
would instead dispatch on the file extension.  So read("x.csv") would
call read.csv, read("cache.rds") would use readRDS etc. Of course it
doesn't work in complete generality, but it's a fun idea to think
about.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/



[Rd] readRDS and saveRDS
Hadley Wickham