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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:29:10+00:00 2026-05-17T19:29:10+00:00

I am using plyr package in R to do the following: pick up a

  • 0

I am using plyr package in R to do the following:

  • pick up a row from table A according to column A and column B
  • find the row from table B having the same value in column A and column B
  • copy column C from table B to table A

I have made the progress bar to show the progress, but after it shows to 100% it seems to be still running, as I have see my CPU is still occupied by RGUI, but it just doesn’t end.

My table A is having about 40000 rows of data with unique column A and column B.

I suspect that the “combine” part of the “split-conquer-combine” workflow in plyr cannot handle this 40000 rows of data, because I can do it for another table with 4000 rows of data.

Any suggestions for improving the efficiency? Thanks.

UPDATE

Here is my code:

for (loop.filename in (1:nrow(filename)))
  {print("infection source merge")
   print(filename[loop.filename, "table_name"])
   temp <- get(filename[loop.filename, "table_name"])
   temp1 <- ddply(temp,
                  c("HOSP_NO", "REF_DATE"),
                  function(df)
                    {temp.infection.source <- abcde[abcde[,"Case_Number"]==unique(df[,"HOSP_NO"]) &
                                              abcde[,"Reference_Date"]==unique(df[,"REF_DATE"]),
                                              "Case_Definition"]
                     if (length(temp.infection.source)==0) {
                         temp.infection.source<-"NIL"
                         } else {
                         if (length(unique(temp.infection.source))>1) {
                             temp.infection.source<-"MULTIPLE"
                             } else {
                            temp.infection.source<-unique(temp.infection.source)}}
                     data.frame(df,
                                INFECTION_SOURCE=temp.infection.source)
                     },
                    .progress="text")
   assign(filename[loop.filename, "table_name"], temp1)
  }
  • 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-17T19:29:11+00:00Added an answer on May 17, 2026 at 7:29 pm

    If I understood correctly what you’re trying to achieve, this should do what you want, pretty quick, and without too much memory loss.

    #toy data
    A <- data.frame(
        A=letters[1:10],
        B=letters[11:20],
        CC=1:10
    )
    
    ord <- sample(1:10)
    B <- data.frame(
        A=letters[1:10][ord],
        B=letters[11:20][ord],
        CC=(1:10)[ord]
    )
    #combining values
    A.comb <- paste(A$A,A$B,sep="-")
    B.comb <- paste(B$A,B$B,sep="-")
    #matching
    A$DD <- B$CC[match(A.comb,B.comb)]
    A
    

    This applies only if the combinations are unique. If they’re not, you’ll have to take care of that first. Without the data it’s quite impossible to know what you’re trying to achieve exactly in your complete function, but you should be able to port the logic given here to your own case.

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

Sidebar

Related Questions

Hadley turned me on to the plyr package and I find myself using it
I am using the plyr package to process lists and data frames. I have
I'm going to use the sample code from http://gettinggeneticsdone.blogspot.com/2009/11/split-apply-and-combine-in-r-using-plyr.html for this example. So, first,
I'm usually using reshape package to aggregate some data (d'uh), usually with plyr ,
I'm using the sqldf package in R and am trying to find the count
I am trying to calculate a rolling mean using plyr. The data is at
Using a populated Table Type as the source for a TSQL-Merge. I want to
I'm using the XML package to scrape a list of websites. Specifically, i'm taking
Using mercurial, I've run into an odd problem where a line from one committer
The advantage of using plyr 's llply over lapply is that it preserves list

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.