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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:44:24+00:00 2026-05-30T13:44:24+00:00

Other posts suggested that ddply is a good workhorse. I am trying to learn

  • 0

Other posts suggested that ddply is a good workhorse.
I am trying to learn xxply functions and I can not solve this problem.

This is my

library(ggplot2)
(df= tips[1:5,])
             total_bill                   tip    sex smoker day   time size
1 16.989999999999998437 1.0100000000000000089 Female     No Sun Dinner    2
2 10.339999999999999858 1.6599999999999999201   Male     No Sun Dinner    3
3 21.010000000000001563 3.5000000000000000000   Male     No Sun Dinner    3
4 23.679999999999999716 3.3100000000000000533   Male     No Sun Dinner    2
5 24.589999999999999858 3.6099999999999998757 Female     No Sun Dinner    4

and I need to something like this

ddply(df
       ,.(<do I have to enumerate all columns I need to operate on here?)>
       , function(x) {if size>=3 return(size) else return(total_bill+tip)
     )

(the example is a fake problem (does not make real life sense) and only demonstrates my problem with larger data)

  1. I could not get the ddply code right reading just help files. Any advise appreciated. Or even great ddply tutorial?

  2. I like that with ddply I can just pass my dataframe as input, but in the second argument, it is not nice that I am forced to enumerate all columns that I need later. Is there a way to pass the whole row (all columns)?

  3. I like defining the function on the fly, but I am not sure how to make my pseudocode correct in R (my last argument).

  • 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-30T13:44:25+00:00Added an answer on May 30, 2026 at 1:44 pm

    Based on your code, it doesn’t look like you need to use plyr here at all. It seems to me you are calculating a new variable for each row of the data.frame. If that’s the case, then just use some base R functions:

    dat <- transform(dat, newval = ifelse(size >= 3, size, total_bill + tip))
    
      total_bill  tip    sex smoker day   time size newval
    1      16.99 1.01 Female     No Sun Dinner    2  18.00
    2      10.34 1.66   Male     No Sun Dinner    3   3.00
    3      21.01 3.50   Male     No Sun Dinner    3   3.00
    4      23.68 3.31   Male     No Sun Dinner    2  26.99
    5      24.59 3.61 Female     No Sun Dinner    4   4.00
    

    Sorry if I misunderstood what you are doing. If you do in fact need to pass the entire row of a data.frame into plyr with no grouping variable, perhaps you can treat it as an array with margin = 1? i.e adply(dat, 1, ...)

    Great introduction of plyr here: http://www.jstatsoft.org/v40/i01/paper

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are other posts that say you can create a control in windows forms
I've read the other posts here about this topic, but I can't seems to
I've been reading through the other posts on this topic tried what was suggested
I've seen various other posts about this, but unfortunately I still haven't been able
I have checked few other posts and found some UIAnimation transitions that kind-of give
Unlike the other posts about the task delete all tables, this question is specifically
I've read through some of the other posts and followed their suggested advice but
This question seems similar to those asked in a few other posts: here and
I have looked at other posts and can't see what I'm doing wrong. I'm
I know there are so many posts about issues like this, but I can

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.