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

  • SEARCH
  • Home
  • 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 8470581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:33:34+00:00 2026-06-10T16:33:34+00:00

So I have a data frame, say with following data: Count Amount Org Bank

  • 0

So I have a data frame, say with following data:

    Count    Amount    Org         Bank
------------------------------------------
      1        100      ABC       Chase
      15        76       DEF    American Express
    ...
    ...

When I run the ddply using:

result1 <- ddply(df, 4, count = sum(as.numeric(df[[1]])), amt = sum(as.numeric(df[[2]])))

I get the result with result1 having the same value (i.e. count and amt) for all rows i.e.

 description      count        amt
  Chase             900        432087
  American Express  900        432087
.....

which is definitely not the case. Somehow, it seems like the last sum() value being calculated is applied to all the rows. Am I missing something here?

  • 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-10T16:33:36+00:00Added an answer on June 10, 2026 at 4:33 pm

    There are a few problems here:

    1. You are gettting the same/wrong result because you are referring back to the original dataframe df in the arguments to ddply – e.g. df[[1]].
      Ddply doesn’t work like that – use column names directly, e.g. Amount and Count.

    2. You are missing the .fun function argument to ddply – in this case summarize is appropriate.
      (I honestly don’t know how your code worked at all without this.)

    3. You are using an undocumented way (4) to select group columns in the .variable argument. Try .(Bank) or c("Bank") instead.

    This should work:

    ddply(df, .(Bank), summarize, count = sum(as.numeric(Count)),
                                  amt = sum(as.numeric(Amount)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the following data frame: > myvec name order_no 1 Amy
Let's say you have a data frame generated by the following commands: date <-
Let's say I have a data.frame like: a <- c(1:10,1:10,1:10,1:10,1:10,1:10,1:10,1:10,1:10,1:10) df <- data.frame(a,rnorm(100)) And
Say I have a dataframe source <- data.frame(ID=c(1,2), COUNT=c(3,4)) that looks like this: ID
Let's say I have the following data frame. dat <- data.frame(city=c(Chelsea,Brent,Bremen,Olathe,Lenexa,Shawnee), tag=c(rep(AlabamaCity,3), rep(KansasCity,3))) I
Let's say I have the following dataset bodysize=rnorm(20,30,2) bodysize=sort(bodysize) survive=c(0,0,0,0,0,1,0,1,0,0,1,1,0,1,1,1,0,1,1,1) dat=as.data.frame(cbind(bodysize,survive)) I'm aware that
Say I have the following R data.frame ZZZ : ( ZZZ <- structure(list(n =
Let say I have the following data frame in R: df1 <- data.frame(Item_Name =
Let's say I have the following data frame with a series of keywords, and
All right, let's say I have the following plot. df = data.frame(date=c(rep(2008:2013, by=1)), value=c(303,407,538,696,881,1094))

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.