Søren Højsgaard
2007-Nov-20 12:01 UTC
[R] Use and misuse of "update" function for non-models. Any views/recommendations??
Dear all, I wonder if it is "bad style" (or something worse) to create an "update" function which does not work on model objects of the lm, glm etc. type. Specifically, I have some graph objects (graphs as mathematical objects, not as displays) which I want to alter and for that purpose I thought of writing an update function. Would doing so violate a "deeper philosophy" in the R system or have other unfortunate consequences. If so, I'm happy to hear other suggestions... Regards S?ren
Gabor Grothendieck
2007-Nov-20 12:12 UTC
[R] Use and misuse of "update" function for non-models. Any views/recommendations??
If you write an update.X method where X is the class of your graph objects then it will work on your graph objects and yet still work on lm, glm, etc. On Nov 20, 2007 7:01 AM, S?ren H?jsgaard <Soren.Hojsgaard at agrsci.dk> wrote:> Dear all, > > I wonder if it is "bad style" (or something worse) to create an "update" function which does not work on model objects of the lm, glm etc. type. Specifically, I have some graph objects (graphs as mathematical objects, not as displays) which I want to alter and for that purpose I thought of writing an update function. Would doing so violate a "deeper philosophy" in the R system or have other unfortunate consequences. If so, I'm happy to hear other suggestions... > > Regards > S?ren
Prof Brian Ripley
2007-Nov-20 13:17 UTC
[R] Use and misuse of "update" function for non-models. Any views/recommendations??
update() is generic, so the recommended approach would be to write a method for your objects. Creating your own function update() in a package would probably not break too much, as namespaces would protect most functions using the generic in stats. But it could be very confusing to users. On Tue, 20 Nov 2007, S?ren H?jsgaard wrote:> Dear all, > > I wonder if it is "bad style" (or something worse) to create an "update" > function which does not work on model objects of the lm, glm etc. type. > Specifically, I have some graph objects (graphs as mathematical objects, > not as displays) which I want to alter and for that purpose I thought of > writing an update function. Would doing so violate a "deeper philosophy" > in the R system or have other unfortunate consequences. If so, I'm happy > to hear other suggestions... > > Regards > S?ren > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Brian D. Ripley, ripley at 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Seemingly Similar Threads
- Fwd: How to sample from a linear mixed model
- Calling substitute(expr, list(a=1)) when expr <- expression(a+b+c)
- Drawing a graph with vertices and edges using tcl/tk
- Computer algebra in R - would that be an idea??
- lattice/xyplot: plotting 4 variables in two panels - can this be done?