Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6569779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:40:29+00:00 2026-05-25T14:40:29+00:00

The documentation for aggregate states: ‘aggregate.formula’ is a standard formula interface to ‘aggregate.data.frame’. I

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:40:29+00:00Added an answer on May 25, 2026 at 2:40 pm

    Jump to the middle of the examples section of help(aggregate) and you will see this:

     ## Formulas, one ~ one, one ~ many, many ~ one, and many ~ many:
     aggregate(weight ~ feed, data = chickwts, mean)
     aggregate(breaks ~ wool + tension, data = warpbreaks, mean)
     aggregate(cbind(Ozone, Temp) ~ Month, data = airquality, mean)
     aggregate(cbind(ncases, ncontrols) ~ alcgp + tobgp, data = esoph, sum)
    

    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:

    R> class(weight ~ feed)
    [1] "formula"
    R> class(chickwts)
    [1] "data.frame"
    

    so aggregate dispatches on it first argument (of class formula). The way a formula gets resolved in R typically revolves around a model.matrix, I presume something similar happens here and an equivalent call is eventually execucted by aggregate.data.frame, using the second argument chickwts, a data.frame.

    R> aggregate(weight ~ feed, data = chickwts, mean)
           feed  weight
    1    casein 323.583
    2 horsebean 160.200
    3   linseed 218.750
    4  meatmeal 276.909
    5   soybean 246.429
    6 sunflower 328.917
    R> 
    

    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 from stats namespace, but you can look at it by typing stats:::aggregate.formula at the prompt — which then clearly shows that it does, in fact, dispatch to aggregate.data.frame():

     [.... some code omitted ...]
        if (is.matrix(mf[[1L]])) {
            lhs <- as.data.frame(mf[[1L]])
            names(lhs) <- as.character(m[[2L]][[2L]])[-1L]
            aggregate.data.frame(lhs, mf[-1L], FUN = FUN, ...)
        }
        else aggregate.data.frame(mf[1L], mf[-1L], FUN = FUN, ...)
    }
    <environment: namespace:stats>
    R> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Documentation states that interface delegation is available for Win32 only. Currently I can't test
Documentation for the constructor new Boolean(boolean value) in Java states: Note: It is rarely
Documentation simply states that setting setAutosavingDelay to anything > 0 on the shared doc
Documentation states: Adds a user-defined custom member to an instance of a Windows PowerShell
The documentation for the round() function states that you pass it a number, and
I've looked all over for some documentation on this, but haven't found it. Some
I'm a little bit stuck with the new ContactsContract-API here. I think I don't
The C2DM documentation states that Google limits the number of messages a sender sends
As of 5/2011 the google documentation for c2dm says this: Google limits the number
Documentation on the flex getTimer() method states: int - The number of milliseconds since

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.