Henrik Bengtsson
2007-Aug-24 19:07 UTC
[Rd] Suggestion: Making attach() and detach() generic
Hi, I would like to suggest to make base::attach() and base::detach() generic, in order to attach/detach fields of other containers ("databases") than the currently supported ones. According to help on attach(), one could dispatch on (first) argument 'what'): what: "database". This may currently be a 'data.frame' or a 'list' or a R data file created with 'save' or 'NULL' or an environment. See also Details. So, in S3 terms, something like: attach(): attach.data.frame() attach.list() attach.environment() attach.character() attach.default() detach() could be extended in a similar way. The first step to make attach()/detach() generic would to justed rename the current attach() to attach.default() and ditto for detach(). [I haven't investigated all the side effects of doing this; there could be problems with substitute():s etc.] Comments? I would be happy to do the mods, if wanted. Cheers Henrik