[R] Generic Function read?
Leonard Mada
|eo@m@d@ @end|ng |rom @yon|c@eu
Tue Feb 28 21:00:18 CET 2023
Dear R-Users,
I noticed that *read* is not a generic function. Although it could
benefit from the functionality available for generic functions:
read = function(file, ...) UseMethod("read")
methods(read)
# [1] read.csv read.csv2 read.dcf read.delim read.delim2
read.DIF read.fortran
# [8] read.ftable read.fwf read.socket read.table
The users would still need to call the full function name. But it seems
useful to be able to find rapidly what formats can be read; including
with other packages (e.g. for Excel, SAS, ... - although most packages
do not adhere to the generic naming convention, but maybe they will
change in the future).
Note:
This should be possible (even though impractical), but actually does NOT
work:
read = function(file, ...) UseMethod("read")
file = "file.csv"
class(file) = c("csv", class(file));
read(file)
Should it not work?
Sincerely,
Leonard
More information about the R-help
mailing list