Dear R-ers,

My aggregation saga continues.

Using the following sequence, I can calculate any statistic for row groups and merge the result back to all associated rows ...

> WM = by( D60, D60[ "KeyProfA"], FUN=function(x) weighted.mean( x$IAC, x$Wt))

> D60$IAC.WM = as.numeric( WM[ D60$KeyProfA])

> class( WM)
[1] "by"

Questions ...

1) Is this a reasonable way to obtain the desired result?

2) What can one glean by knowing the class of WM ("by")? It appears to me that class is a pretty shallow attribute in R ... just an associated string that selects among methods in some contexts. Is that really all there is to it? Is there a way to discover what generic methods are aware of a given class? In other words, who cares if WM is a "by" ... what does that do for me?

In my traditional universe (C++) I can grep and discover what methods are virtual, who inherits from whom, etc. In R, the documentation appears silent on what is a "by" (correct me if I'm wrong). In addition, I have found no way to broadly search code to learn things. (Displaying single functions is useful but hardly broad.)

How does one learn R more efficiently than randomly discovering how to avoid error messages? (For example, I now know that a "by" cannot be coerced into a data.frame (although it seems to me that such a conversion could be usefully defined), so now I don't hit myself on the head with that particular hammer.)

Chip Barnaby






---------------------------------------------------------
Chip Barnaby                   [EMAIL PROTECTED]
Vice President of Research
Wrightsoft Corp.               781-862-8719 x118 voice
131 Hartwell Ave               781-861-2058 fax
Lexington, MA 02421         www.wrightsoft.com

______________________________________________
R-help@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.

Reply via email to