Gregory Warnes
2001-May-23 18:37 UTC
[Rd] New generic functions in "R base" {was `truncate'}
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---2088752589-1867062326-990643072=:2129 Content-Type: TEXT/PLAIN; charset=US-ASCII 1) What are the issues with making _existing_ functions in base into generics? EG, I've recently become annoyed that plot() is a generic which can be applied to a formula: plot( outcome ~ predictor) but functions like points, lowess, etc are not generic or don't have methods defined for formulae. I've created a points.formula() and a generic lowess(), lowess.default(), and lowess.formula(). Are there any problems in replacing the current points() with a generic function, provided that the default function does the same thing as the original function? 2) I have a couple of other functions I just want to throw out: - A generic ci() (for confidence interval) with a method for lm and summary.lm. - The function boxplot.n which gives a standard boxplot annotated with the number of observations in each group. -Greg Files are attached ---2088752589-1867062326-990643072=:2129 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="boxplot.n.R" Content-Transfer-Encoding: BASE64 Content-ID: <Pine.LNX.3.96.1010523203752.2129B@luthien.ci.tuwien.ac.at> Content-Description: IyBjcmVhdGUgYSBib3hwbG90IGFuZCBhbm5vdGF0ZSB3aXRoIHRoZSBudW1i ZXIgb2Ygb2JzZXJ2YXRpb25zIGluIGVhY2ggZ3JvdXAuDQojDQojIHBhcmFt ZXRlcnMNCiMgIC4uLjogIHN0YW5kYXJkIGJveHBsb3QgcGFyYW1ldGVycw0K Iw0KIyAgdG9wOiAgaWYgVCBwdXQgbidzIGF0IHRvcCBvZiBwbG90dGluZyBy ZWdpb24sIG90aGVyd2lzZSBhdCB0aGUgYm90dG9tLg0KIw0KIyAgc2hyaW5r OiB2YWx1ZSB0byBzaHJpbmsgY2hhcmFjdGVyIHNpemUgd2hlbiBhbm5vdGF0 aW5nLiAgKFRoaXMgdmFsdWUgaXMNCiMgICAgICAgICAgYXBwbGllZCB0byBj ZXguKQ0KIw0KIyAgdGV4dGNvbG9yOiB0ZXh0IGNvbG9yDQojDQojIGV4YW1w bGU6DQojDQojIGRhdGEgIDwtICBkYXRhLmZyYW1lKHk9cm5vcm0oMTAwKSwg eD1mYWN0b3IocmVwKGMoIkEiLCJDIiwiRiIsIloiKSwyNSkpKQ0KDQogYm94 cGxvdC5uKCB5IH4geCwgZGF0YT1kYXRhKQ0KDQoNCg0KYm94cGxvdC5uICA8 LSBmdW5jdGlvbiggLi4uLCB0b3A9Riwgc2hyaW5rPTEuMCwgdGV4dGNvbG9y PU5VTEwgKQ0KICB7DQogICAgYm94IDwtIG1hdGNoLmNhbGwoKSAgICAgICAg ICAgIyBnZXQgY2FsbA0KICAgIGJveCR0b3AgIDwtIGJveCRzaHJpbmcgIDwt IGJveCR0ZXh0Y29sb3IgIDwtIE5VTEwNCiAgICBib3hbWzFdXSAgPC0gYXMu bmFtZSgiYm94cGxvdCIpDQogICAgYm94IDwtIGV2YWwoYm94LCBwYXJlbnQu ZnJhbWUoKSkNCg0KICAgIGlmKHRvcCkNCiAgICAgIHdoZXJlICA8LSBwYXIo InVzciIpWzRdDQogICAgZWxzZQ0KICAgICAgd2hlcmUgIDwtIHBhcigidXNy IilbM10NCiAgICBjZXggPC0gcGFyKCJjZXgiKQ0KICAgIHBhcihjZXg9c2hy aW5rKmNleCkNCiAgICB0ZXh0KCB4PTE6bGVuZ3RoKGJveCRuKSwgeT13aGVy ZSwgbGFiZWxzPXBhc3RlKCJuPSIsYm94JG4sc2VwPSIiKSwgYWRqPWMoMC41 LDApLA0KICAgICAgICAgY29sPXRleHRjb2xvcikNCiAgICBwYXIoY2V4PWNl eCkNCg0KICAgIGludmlzaWJsZShib3gpDQogIH0NCg=---2088752589-1867062326-990643072=:2129 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="lowess.R" Content-Transfer-Encoding: BASE64 Content-ID: <Pine.LNX.3.96.1010523203752.2129C@luthien.ci.tuwien.ac.at> Content-Description: bG93ZXNzLmRlZmF1bHQgIDwtIGdldCgibG93ZXNzIixwb3M9InBhY2thZ2U6 YmFzZSIpDQoNCmxvd2VzcyAgPC0gZnVuY3Rpb24oeCwuLi4pDQogIFVzZU1l dGhvZCgibG93ZXNzIikNCg0KImxvd2Vzcy5mb3JtdWxhIiA8LQ0KICBmdW5j dGlvbiAoZm9ybXVsYSwgZGF0YSA9IE5VTEwsIHN1YnNldCwgbmEuYWN0aW9u LCAuLi4pIA0Kew0KICBpZiAobWlzc2luZyhmb3JtdWxhKSB8fCAobGVuZ3Ro KGZvcm11bGEpICE9IDMpKSANCiAgICBzdG9wKCJmb3JtdWxhIG1pc3Npbmcg b3IgaW5jb3JyZWN0IikNCiAgaWYgKG1pc3NpbmcobmEuYWN0aW9uKSkgDQog ICAgbmEuYWN0aW9uIDwtIGdldE9wdGlvbigibmEuYWN0aW9uIikNCiAgbSA8 LSBtYXRjaC5jYWxsKGV4cGFuZC5kb3RzID0gRkFMU0UpDQogIGlmIChpcy5t YXRyaXgoZXZhbChtJGRhdGEsIHBhcmVudC5mcmFtZSgpKSkpIA0KICAgIG0k ZGF0YSA8LSBhcy5kYXRhLmZyYW1lKGRhdGEpDQogIG0kLi4uIDwtIE5VTEwN CiAgbVtbMV1dIDwtIGFzLm5hbWUoIm1vZGVsLmZyYW1lIikNCiAgbWYgPC0g ZXZhbChtLCBwYXJlbnQuZnJhbWUoKSkNCiAgcmVzcG9uc2UgPC0gYXR0cihh dHRyKG1mLCAidGVybXMiKSwgInJlc3BvbnNlIikNCiAgbG93ZXNzKG1mW1st cmVzcG9uc2VdXSwgbWZbW3Jlc3BvbnNlXV0sIC4uLikNCn0NCg=---2088752589-1867062326-990643072=:2129 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="points.formula.R" Content-Transfer-Encoding: BASE64 Content-ID: <Pine.LNX.3.96.1010523203752.2129D@luthien.ci.tuwien.ac.at> Content-Description: InBvaW50cy5mb3JtdWxhIiA8LQ0KICBmdW5jdGlvbiAoZm9ybXVsYSwgZGF0 YSA9IE5VTEwsIHN1YnNldCwgbmEuYWN0aW9uLCAuLi4pIA0Kew0KICBpZiAo bWlzc2luZyhmb3JtdWxhKSB8fCAobGVuZ3RoKGZvcm11bGEpICE9IDMpKSAN CiAgICBzdG9wKCJmb3JtdWxhIG1pc3Npbmcgb3IgaW5jb3JyZWN0IikNCiAg aWYgKG1pc3NpbmcobmEuYWN0aW9uKSkgDQogICAgbmEuYWN0aW9uIDwtIGdl dE9wdGlvbigibmEuYWN0aW9uIikNCiAgbSA8LSBtYXRjaC5jYWxsKGV4cGFu ZC5kb3RzID0gRkFMU0UpDQogIGlmIChpcy5tYXRyaXgoZXZhbChtJGRhdGEs IHBhcmVudC5mcmFtZSgpKSkpIA0KICAgIG0kZGF0YSA8LSBhcy5kYXRhLmZy YW1lKGRhdGEpDQogIG0kLi4uIDwtIE5VTEwNCiAgbVtbMV1dIDwtIGFzLm5h bWUoIm1vZGVsLmZyYW1lIikNCiAgbWYgPC0gZXZhbChtLCBwYXJlbnQuZnJh bWUoKSkNCiAgcmVzcG9uc2UgPC0gYXR0cihhdHRyKG1mLCAidGVybXMiKSwg InJlc3BvbnNlIikNCiAgcG9pbnRzKG1mW1stcmVzcG9uc2VdXSwgbWZbW3Jl c3BvbnNlXV0sIC4uLikNCn0NCg=---2088752589-1867062326-990643072=:2129 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="ci.R" Content-Transfer-Encoding: BASE64 Content-ID: <Pine.LNX.3.96.1010523203752.2129E@luthien.ci.tuwien.ac.at> Content-Description: Y2kgIDwtICBmdW5jdGlvbih4LC4uLikgVXNlTWV0aG9kKCJjaSIpDQoNCmNp LnN1bW1hcnkubG0gIDwtICBmdW5jdGlvbih4LGNvbmZpZGVuY2U9MC45NSxh bHBoYT0xLWNvbmZpZGVuY2UpIHsNCiAgZXN0ICA8LSAgY29lZih4KVssMV0g Ow0KICBjaS5sb3cgIDwtIGVzdCArIHF0KGFscGhhLzIsIHgkZGZbMl0pICog Y29lZih4KVssMl0gOw0KICBjaS5oaWdoIDwtIGVzdCAtIHF0KGFscGhhLzIs IHgkZGZbMl0pICogY29lZih4KVssMl0gOw0KICByZXR2YWwgIDwtIGNiaW5k KEVzdGltYXRlPWVzdCwNCiAgICAgICAgICAgICAgICAgICAiQ0kgbG93ZXIi PWNpLmxvdywNCiAgICAgICAgICAgICAgICAgICAiQ0kgdXBwZXIiPWNpLmhp Z2gsDQogICAgICAgICAgICAgICAgICAgIlN0ZC4gRXJyb3IiPSBjb2VmKHgp WywyXSwNCiAgICAgICAgICAgICAgICAgICAicC12YWx1ZSIgPSBjb2VmKHgp Wyw0XSkNCiAgcm93bmFtZXMocmV0dmFsKSAgPC0gIHJvd25hbWVzKGNvZWYo eCkpDQogIHJldHZhbA0KfQ0KDQpjaS5sbSAgPC0gIGZ1bmN0aW9uKHgsLi4u KQ0Kew0KICB4ICA8LSAgc3VtbWFyeSh4KQ0KICByZXR1cm4oY2kuc3VtbWFy eS5sbSh4KSkNCn0NCg0K ---2088752589-1867062326-990643072=:2129-- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter Dalgaard BSA
2001-May-23 19:12 UTC
[Rd] New generic functions in "R base" {was `truncate'}
Gregory Warnes <warnes@ci.tuwien.ac.at> writes:> EG, I've recently become annoyed that plot() is a generic which can be > applied to a formula: > > plot( outcome ~ predictor) > > but functions like points, lowess, etc are not generic or don't have > methods defined for formulae. I've created a points.formula() and a > generic lowess(), lowess.default(), and lowess.formula(). > > Are there any problems in replacing the current points() with a generic > function, provided that the default function does the same thing as the > original function?Ummm, points.formula has been in base R since february 2000... slipped in between 0.99.0 and 1.0.0 apparently. Also note that loess() (with the correct spelling, in the modreg library) does have a formula interface. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Prof Brian Ripley
2001-May-23 19:33 UTC
[Rd] New generic functions in "R base" {was `truncate'}
On Wed, 23 May 2001, Gregory Warnes wrote:> 1) What are the issues with making _existing_ functions in base into > generics?There are some performance issues (not necessarily relevant here). Last time I looked hard at this method dispatch was taking ca 0.2 secs (not on my fastest machines ....), and some generics turn up rather high on profiling list rather often. The other issue I see is the argument list for the generic, given that all method ought to agree with the generic (at least aesthetically). [...] -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
kjetil halvorsen
2001-May-23 19:39 UTC
[Rd] New generic functions in "R base" {was `truncate'}
Gregory Warnes wrote:> > 1) What are the issues with making _existing_ functions in base into > generics? > > EG, I've recently become annoyed that plot() is a generic which can be > applied to a formula: > > plot( outcome ~ predictor) > > but functions like points, lowess, etc are not generic or don't have > methods defined for formulae. I've created a points.formula() and a > generic lowess(), lowess.default(), and lowess.formula().lowess is supposed to handle formulas and will do so when the scope error in xy.coords is corrected. Kjetil Halvorsen -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._