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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:13:07+00:00 2026-06-09T13:13:07+00:00

I am stuck in a small thing. I have a data frame in R

  • 0

I am stuck in a small thing. I have a data frame in R like this

chrom exonCount
chr1         3
chr1         4
chr1         5
chr1         5
chr1         9
chr1        10
chr2         7
chr2        11
chr2        13
chr3         7
chr4         7

I just want the output as

chr1        36
chr2        31
chr3         7
chr4         7

I assume the aggregate function can do that but I am lost in usage.

Thanks

  • 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-09T13:13:09+00:00Added an answer on June 9, 2026 at 1:13 pm

    I think the plyr package does this the clearest, but using base R

    dat <- structure(list(chrom = c("chr1", "chr1", "chr1", "chr1", "chr1", 
    "chr1", "chr2", "chr2", "chr2", "chr3", "chr4"), exonCount = c(3L, 
    4L, 5L, 5L, 9L, 10L, 7L, 11L, 13L, 7L, 7L)), .Names = c("chrom", 
    "exonCount"), class = "data.frame", row.names = c(NA, -11L))
    
    aggregate(data=dat, exonCount ~ chrom, FUN=sum)
    
      chrom exonCount
    1  chr1        36
    2  chr2        31
    3  chr3         7
    4  chr4         7
    > 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am stuck at a small problem. I have this button within a form
It's a small thing, really: I have this function that converts dict objects to
I have just written a small piece of code and it struck me that
I am stuck in a very difficult condition. I have made some small projects
I have written a small web app to collect some data and store it
I have this problem. So I have a bunch of data that must be
I'm stuck on one small problem that stop development for a feature I'm trying
I am stuck with a small problem here.. What i am trying to do
I wrote some small apps using .NET 3.5 but now I am stuck with
I have made a rediculasly small snippet to make a sub-header stick to the

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.