The documentation for aggregate states:
‘aggregate.formula’ is a standard formula interface to ‘aggregate.data.frame’.
I am new to R, and I don’t understand what this means. Please explain!
Thanks!
Uri
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Jump to the middle of the examples section of
help(aggregate)and you will see this:Four different calls to
aggregate(), all using the formula interface. The way it is written above in what you quote has to do with method dispatching mechanism used throughout R.Consider the first example:
so aggregate dispatches on it first argument (of class
formula). The way a formula gets resolved in R typically revolves around amodel.matrix, I presume something similar happens here and an equivalent call is eventually execucted byaggregate.data.frame, using the second argumentchickwts, adata.frame.What you asked isn’t the easiest beginner question, I’d recommend a good thorough look at some of the documentation and a decent R book if you have one handy. (And other SO questions give recommendation as to what to read next.)
Edit: I had to dig a little as
aggregate.formula()is not exported fromstatsnamespace, but you can look at it by typingstats:::aggregate.formulaat the prompt — which then clearly shows that it does, in fact, dispatch toaggregate.data.frame():