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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:56:44+00:00 2026-05-29T06:56:44+00:00

Considering the following data frames : > tail(tot.final) names.id sequence names.reads width.reads names.counts st

  • 0

Considering the following data frames :

 > tail(tot.final)
   names.id                  sequence names.reads width.reads names.counts st end flag
819   125546  TAGCTTATATGACTGATGTTGACA    125546-4          24            4  8  31 TRUE
820   218783  TCGCTTATCAGACTGATGTTGAAA    218783-2          24            2  8  31 TRUE
821   272992  CAGCTTATCAGACTGATGTTGAAA    272992-2          24            2  8  31 TRUE
822   135191 TAGCTTATCAGACTGATGTTGAACA    135191-4          25            4  8  32 TRUE
823   278047 TAGCTTATCAGACTGATGTTGAAGA    278047-2          25            2  8  32 TRUE
824   317980 TAGCTTATCAGACTGATGTTGCCCT    317980-2          25            2  8  32 TRUE

head(plusa)
  names.id            sequence names.reads width.reads names.counts st end flag
2     28092   ATCAGACTGATGTTGAC    28092-29          17           29 14  30 TRUE
4     65308  TTATCAGACTGATGTTGA    65308-10          18           10 12  29 TRUE
6     71226  TATCAGACTGATGTTGAC     71226-9          18            9 13  30 TRUE

> nrow(tot.final)
[1] 824
> nrow(plusa)
[1] 421

plusa contains 451 rows with a  common plusa$sequence column. (not sorted)

I would like to update tot.final$names.counts elements by adding the plusa$names.counts values of the corresponding plusa$sequence.

Is there a possiblity to merge them in this manner considering the “sequence” field as id?

  • 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-29T06:56:45+00:00Added an answer on May 29, 2026 at 6:56 am

    As far as I can understand, I think this is what you want to do:

    1. join (say rbind) plusa to tot.final
    2. for each unique sequence in this data frame:
      sum up the counts column.

    In that case, you can use the plyr library. I made up an example to illustrate, you should e able to adapt it to yours:

    library(plyr)
    df.final <- data.frame(sequence=c('A','B','C','D'),
                           counts=c(100,123,234,200),
                           stringsAsFactors=F)
    #   sequence counts
    # 1        A    100
    # 2        B    123
    # 3        C    234
    # 4        D    200
    
    df.plusa <- data.frame(sequence=c('A','E','C','F'),
                           counts=c(10,20,30,40),
                           stringsAsFactors=F)
    #   sequence counts
    # 1        A     10
    # 2        E     20
    # 3        C     30
    # 4        F     40
    
    # rbind together and do the counts:
    df.final.aggregated <- ddply(rbind(df.final,df.plusa),
                                 .(sequence),
                                 summarise,
                                 counts=sum(counts))
    #   sequence counts
    # 1        A    110
    # 2        B    123
    # 3        C    264
    # 4        D    200
    # 5        E     20
    # 6        F     40
    

    Note that ddply(dataframe,.(sequence),FUNCTION) means:

    for each unique seq in dataframe$sequence:
        do FUNCTION( dataframe[ dataframe$sequence==seq, ] )
        merge them all back into one big dataframe.
    

    For your particular data this could work (haven’t tested as I don’t have your data):

    ddply( rbind(tot.final,plusa), .(sequence), summarise,
           names.counts = sum(names.counts) )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm considering the following: I have some data stream which I'd like to protect
Considering the following data example : data ={ {a, b, c, d, e}, {1,
Considering the following html: <div id=test data-test='[foo, bar]'></div> and the following javascript: var dataValue
In SQL Server 2008 R2, Considering the following xml DECLARE @xml xml = '<data><fr>Chambre
Considering following code public class A { public static void main(String[] args) { new
Considering the following architecture: a base object 'Entity' a derived object 'Entry:Base' and a
Considering the following table: someId INTEGER #PK ageStart TINYINT(3) ageEnd TINYINT(3) dateBegin INTEGER dateEnd
considering the following enum: public enum LeadStatus { Cold = 1, Warm = 2,
I'm facing the following problems: We have meta data for items, each item can
Considering the following record types: type drCode1Body = {DrCode : byte ; Name :

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.