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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:46:15+00:00 2026-05-25T23:46:15+00:00

I have two matrix with the same number of columns, but with different number

  • 0

I have two matrix with the same number of columns, but with different number of rows:

a <- cbind(runif(5), runif(5))
b <- cbind(runif(8), runif(8))

I want to associate these in a same list, so that the first columns of a and b are associated with each other, and so on:

my_result <- list(list(a[,1], b[,1]), list(a[,2], b[,2]))

So the result would look like this:

> print(my_result)
[[1]]
[[1]][[1]]
[1] 0.9440956 0.7259602 0.7804068 0.7115368 0.2771190

[[1]][[2]]
[1] 0.4155642 0.1535414 0.6983123 0.7578231 0.2126765 0.6753884 0.8160817
[8] 0.6548915

[[2]]
[[2]][[1]]
[1] 0.7343330 0.7751599 0.4463870 0.6926663 0.9692621

[[2]][[2]]
[1] 0.5708726 0.1234482 0.2875474 0.4760349 0.2027653 0.5142006 0.4788264
[8] 0.7935544

I can’t figure how to do that without a for loop, but I’m pretty sure some *pply magic could be used here.

Any directions would be much appreciated.

  • 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-25T23:46:16+00:00Added an answer on May 25, 2026 at 11:46 pm

    I’m not sure how general a solution you’re looking for (arbitrary number of matrices, ability to pass a list of matrices, etc.) but this works for your specific example:

    lapply(1:2,function(i){list(a[,i],b[,i])})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays containing the same elements, but in different orders, and I
I have a quadratic matrix(two-dimensional dynamic array of pointers) and need to change rows/columns
I have a code base, in which for Matrix class, these two definitions are
Assume I have one matrix with two columns. Every column has thousands of values.
Suppose I have a two column matrix. How do I pack the columns into
I have a list-of-list-of-lists, where the first two act as a matrix, where I
I have two exact same codes OpenGL C++ , compiled using VS2008 in different
In short: I have two matrices (or arrays): import numpy block_1 = numpy.matrix([[ 0,
I have two strings both with value null . But when I am comparing
I have two images they actually do not overlap but I also can't have

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.