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 8989405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:15:03+00:00 2026-06-15T22:15:03+00:00

I am having a terrible time running ‘ddply’ over two variables in what seems

  • 0

I am having a terrible time running ‘ddply’ over two variables in what seems like it should be a simple command.

Sample data (df):

Brand    Day     Rev     RVP              
  A      1        2535.00  195.00 
  B      1        1785.45  43.55 
  C      1        1730.87  32.66 
  A      2        920.00   230.00
  B      2        248.22   48.99 
  C      3        16466.00 189.00      
  A      1        2535.00  195.00 
  B      3        1785.45  43.55 
  C      3        1730.87  32.66 
  A      4        920.00   230.00
  B      5        248.22   48.99 
  C      4        16466.00 189.00

I am using the command:

df2<-ddply(df, .(Brand, Day), summarize, Rev=mean(Rev), RVP=sum(RVP))

My dataframe has about 2600 observations, and there are 45 levels of “Brand” and up to 300 levels of “Day” (which is coded using ‘difftime’).

I am able to easily use ‘ddply’ when simply grouping by “Day,” but when I also try to group by “Brand,” my computer freezes up.

Thoughts?

  • 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-06-15T22:15:04+00:00Added an answer on June 15, 2026 at 10:15 pm

    You should read through the help pages for aggregate, by, ave, and tapply, paying close attention to the types of the arguments each one of them expects and the names of the arguments as well. Then run all of the examples or demo(). The main thing @hadley did with pkg:plyr and reshape/reshape2 was to impose some degree of regularity, but it was at the expense of speed. I do understand why he did it, especially when I try to use the base::reshape function, but also when I forget as I repeatedly do, which of these requires a list, which requires the FUN= argument label, which needs interaction() for the grouping variable, …. since they are all somewhat different.

    > aggregate(df[3:4], df[1:2], function(d) mean(d) )
       Brand Day       Rev    RVP
    1      A   1  2535.000 195.00
    2      B   1  1785.450  43.55
    3      C   1  1730.870  32.66
    4      A   2   920.000 230.00
    5      B   2   248.220  48.99
    6      B   3  1785.450  43.55
    7      C   3  9098.435 110.83
    8      A   4   920.000 230.00
    9      C   4 16466.000 189.00
    10     B   5   248.220  48.99
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a terrible time trying to get an input box like the
I am having a terrible time trying to do something that should be easy.
I am having a terrible time figuring this one out. I have a form.
I'm having terrible trouble trying to get a navigation controller up-and-running. Basically, I want
I have been having a terrible time trying to compile a python extension -
I am having a terrible time understanding how to get the wrapper to work
I'm having a terrible time trying to pull out some values out of an
My title is terrible but I'm having a hard time wrapping my head around
I'm having a terrible time convincing myself what I've done here is a good
I am having a terrible time getting my height of my DIVs to properly

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.