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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:18:40+00:00 2026-06-13T06:18:40+00:00

I have a problem in R, which I can’t seem to solve. I have

  • 0

I have a problem in R, which I can’t seem to solve.

I have the following dataframe:

Image 1

I would like to:

  1. Find the unique combinations of the columns ‘Species’ and ‘Effects’
  2. Report the concentration belonging to this unique combination
  3. If this unique combination is present more than one time, calculate the mean concentration

And would like to get the following dataframe:

Image 2

I have tried next script to get the unique combinations:

UniqueCombinations <- Data[!duplicated(Data[,1:2]),]

but don’t know how to proceed from there.

Thanks in advance for your answers!

Tina

  • 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-13T06:18:41+00:00Added an answer on June 13, 2026 at 6:18 am

    Try the following (Thanks Brandon Bertelsen for nice comment):

    Creating your data:

    foo = data.frame(Species=c(rep("A",4),"B",rep("C",3),"D","D"), 
                     Effect=c(rep("Reproduction",3), rep("Growth",2),
                              "Reproduction", rep("Mortality",2), rep("Growth",2)), 
                     Concentration=c(1.2,1.4,1.3,1.5,1.6,1.2,1.1,1,1.3,1.4))
    

    Using great package plyr for a bit of magic 🙂

    library(plyr)
    ddply(foo, .(Species,Effect), function(x) mean(x[,"Concentration"]))
    

    And this is a bit more complicated, but cleaner version (Thanks again to Brandon Bertelsen):

    ddply(foo, .(Species,Effect), summarize, mean=mean(Concentration))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem which i can't seem to find the solution to. I
I have a small problem which i can't seem to solve myself. Look at
I have a small problem which I can't seem to find a solution to.
I have a problem which I can't seem to find a different solution for
I have a unique problem to which I can not find a solution. I
I have a small problem which i can't seem to figure out. I tried
I have the following problem: I have a search box in which user can
Once again I have a problem which I can't find the solution to. A
I have a problem at hand which can be reduced to something like this
I have a problem which I'm pretty sure that I can't solve without going

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.