[Rd] readRDS and saveRDS
Hadley Wickham
hadley at rice.edu
Tue Oct 18 22:36:48 CEST 2011
>> 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/
More information about the R-devel
mailing list