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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:30:34+00:00 2026-05-31T23:30:34+00:00

I have 2 separate dataframes df1 ID Name loq 1 a 1.2 1 b

  • 0

I have 2 separate dataframes

df1

ID      Name     loq
1        a       1.2 
1        b       1.4
1        c       1.0
2        a       0.5
2        b       0.7
2        c       0.3
3        a       0.5
3        b       0.2
3        c       0.1        

df2 This is a list of dataframes

[1]  ID     Name   
     1       a 
     3       b
     2       c
     2       a

 [2]  ID     Name
      3      c
      2      b
      2      a
      1      c

The result for df2 would look like this

  [1]  ID     Name   loq 
     1       a     1.2
     3       b     0.2
     2       c     0.3
     2       a     0.5

 [2]  ID     Name    loq
      3      c       0.1
      2      b       0.7
      2      a       0.5
      1      c       1.0

And I have a long list of dataframes.

I would like add match ID AND name from df1 to df2 list and a new variable called loq to the df2 list based on the match.

I know how to do the match variable within a dataframe but don’t know how to match a df to a list of dataframes.

  • 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-31T23:30:35+00:00Added an answer on May 31, 2026 at 11:30 pm

    Keeping to base, it is pretty straight-forward to do what you want:

    # Create the data frames/lists
    df1 <- data.frame(
      ID   = gl(3,3), 
      Name = rep(letters[1:3], 3), 
      loq  = c(1.2, 1.4, 1.0, 0.5, 0.7, 0.3, 0.5, 0.2, 0.1)
    )
    df2 <- list()
    df2[[1]] <- data.frame(ID = factor(c(1, 3, 2, 2)), Name = c('a', 'b', 'c', 'a'))
    df2[[2]] <- data.frame(ID = factor(c(3, 2, 2, 1)), Name = c('c', 'b', 'a', 'c'))
    
    lapply(df2, merge, y = df1)  # merge df2 list elements accordingly to df1
    

    You could also manually specify what to merge on. In this case, it looks for matching column names: c(ID, Name). If you wanted to put df2 into a dataframe, you could do something like

    do.call("rbind.data.frame", df2)  # uses df2 list elements as arguments to rbind
    

    The key here is that the columns ID and Name uniquely define the record (in database terms, they must be a composite primary key for that data table (frame)). In this way, merging (joining) the df2 list elements (data frames) by their matches in df1 will not run into duplication and therefore problems. This is to say, it will work as long as there’s not 2 different rows with the same ID and Name values.

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

Sidebar

Related Questions

Do signal handlers have a separate stack, (like each thread have separate stacks)? This
Harvard architecture computers have separate code and data memories. Does this make them immune
I have a csv that looks like Deamon,Host,1:2:4,aaa.03 Pixe,Paradigm,1:3:5,11.us I need to read this
I have person class and then class like Countries Languages I have separate classes
How to make link like www.facebook.com/Lukavyi ? Must every user have separate php file
I have a table of products with attributes like SKU, Name, etc. It seems
Do I need to have separate/multiple workers to run multiple websites (each with a
What's the best way to have separate CSS for IE and other browsers? I'm
In my ASP.NET application I have separate projects for the Data, Business and UI
I have web application which we deployed in a production . We have separate

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.