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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:47:02+00:00 2026-06-07T06:47:02+00:00

I am trying to write a loop that will summarize my set of matrices

  • 0

I am trying to write a loop that will summarize my set of matrices that all start with the same name plus a number (e.g. “day11”). However, in each run of the loop the number of matrices varies.

Without the loop it can be done once like this:

combmat<-(day1+day3+day4+day5+day6+day8+day9+day10+day11+day12+day13+day14+day15+day16+day17+day18+day19+day20+day22+day23+day24+day25+day26+day27+day28+day29)

I have tried

sum(list=ls(pattern="^day"))

without any luck …

Thank you!

  • 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-07T06:47:03+00:00Added an answer on June 7, 2026 at 6:47 am

    Maybe something like

    day1<-matrix(c(1:4),2,2)
    day2<-matrix(c(1:4),2,2)
    day3<-matrix(c(1:4),2,2)
    day4<-matrix(c(1:4),2,2)
    
    list=ls(pattern="^day")
    
    res<-lapply(list,"get")
    
    do.call("sum",res)
    
    > do.call("sum",res)
    [1] 40
    

    will work for you

    get returns the value of a named object. So get("x") would return the variable x

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

Sidebar

Related Questions

I'm trying to write a unit test that will loop through all action methods
Trying to write a batch file that will loop through all the files in
I'm trying to write a program that will loop through cells of a specific
I am trying to write a script that will submit all the individual forms
I am trying to write a program in Python that will loop to keep
I am trying to write some code that will loop through a list and
I am trying to write a For... Next loop that will allow for 12
I am currently trying to write a script that will loop through multiple directories.
I'm trying to use openmp to multithread a loop through std::set. When I write
I m trying write code that after reset set up rrpmax as 3000. It

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.