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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:14:27+00:00 2026-05-23T11:14:27+00:00

here are my data: l1 <- list(a=1, b=2) l2 <- list(a=10, b=20) I want

  • 0

here are my data:

l1 <- list(a=1, b=2)
l2 <- list(a=10, b=20)

I want to combine them in a component-wise manner. For instance, if I want to add the values of each component of l1 to the values of the same component in l2, I would do:

l <- list(a=l1$a+l2$a, b=l1$b+l2$b)

If now I have several components, I can do:

l <- list()
for(c in names(l1))
    l[[c]] <- l1[[c]] + l2[[c]]

However, my lists can have lots of components, and I may need to do it with more than two lists (each always having the same component names as the others).

Since “for” loops are not recommended in R, is there any way of doing this using something like lapply, or merge, or by…?

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-05-23T11:14:28+00:00Added an answer on May 23, 2026 at 11:14 am

    It seems like you’re looking for Map:

    identical(l, Map("+", l1, l2))
    # [1] TRUE
    

    Which is the same as:

    mapply("+", l1, l2, SIMPLIFY=FALSE)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Data: a dependency list, already verified to be acyclic. So here, 'a' depends on
I must transform some XML data into a paginated list of fields. Here is
ex: <a><strike>example data in here</strike></a> I want everything inside the a tag, to the
I have a problem with my android-app. I want to save a Data-list in
I have an unbalanced quarterly panel data set with missing values. I want to
here is my entire class. I read data from a text file, put them
Hi I am fetching data for List View from web and want to set
My html is like this <div id=rsContainer> <table id=rsTable><!-- DATA HERE --></table> </div> and
Here is my data structure alt text http://luvboy.co.cc/images/db.JPG when i try this sql select
last time I asked how to populate a data structure here . Now I

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.