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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:37:21+00:00 2026-06-13T09:37:21+00:00

I have a basic matrix mat and I hope to get an R object

  • 0

I have a basic matrix mat and I hope to get an R object x = (mat, mat, ...) where mat is repeated for 100 times. If this is possible, then I can pass x to a function which takes a vector of matrix names. I tried rep(mat, 100) but it seems that the matrix class is no longer maintained. Any suggestions? Thanks!

Update: Basically I plan to use

grp.ids <- as.factor(c(rep(1,8), rep(2,4), rep(3,2)))
x <- model.matrix(~grp.ids)
do.call(blockMatrixDiagonal,
             replicate(100, x, simplify=FALSE))

where the blockMatrixDiagonal function can be found here. Then R gives an error: number of items to replace is not a multiple of replacement length. What I really hope to get via these coding is a block diagonal matrix. 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-06-13T09:37:22+00:00Added an answer on June 13, 2026 at 9:37 am

    Your input matrix is not appropriate for building a block diagonal matrix since it’s not a square matrix (i.e., the number of rows equals the number of columns).

    Let me cite two resources on block diagonal matrices.

    1) Wikipedia:

    A block diagonal matrix is a block matrix which is a square matrix, and having main diagonal blocks square matrices

    2) The description of the function blockMatrixDiagonal:

    builds a block matrix whose diagonals are the square matrices provided.


    You can combine your non-square matrices with the function adiag from the package magic. With your matrix x:

    library(magic)
    do.call(adiag, replicate(100, x, simplify = FALSE))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this 3x3 matrix which I'm using to preform basic transformations like translation,
Sorry in advance if this is a really basic Matrix/OpenGl question. I have a
I have a question about numpy.matrix class. How can I perform such basic manipulations
I have basic Spring MVC 3 setup for i18n where I can show labels
I have a basic web service that returns the following object as JSON: public
I have a basic math question. I am trying to get a percentage from
There are many articles in this site regarding my question. I have a matrix
I am new to world of matrix, sorry for this basic question I could
I have 2 2-D NSMutableArrays and I am trying to do some basic matrix
Consider that I have a symmetrical relationship matrix, similar to this: Except that each

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.