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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:43:56+00:00 2026-06-02T07:43:56+00:00

I am not very familiar with using the list function in R. This is

  • 0

I am not very familiar with using the list function in R. This is my first use of a list of matrices. I am trying to remove the same columns from each matrix in a list of matrices but I am not sure how this works with the indexing in R.

Right now I have 8 matrices in a list. Each matrix is [120, 56]. I would like to remove rows columns 17-40 and 49-56 from each matrix. Therefore, I would end up with a list of 8 matrices of [120, 24].

Here is an example of the matrix list I have:

MatrixList <- list(maxT = matrix(1:56, 120, 56, byrow = TRUE),
        minT = matrix(1:56, 120, 56, byrow = TRUE),
        meanT = matrix(1:56, 120, 56, byrow = TRUE),
        rain24 = matrix(1:56, 120, 56, byrow = TRUE),
        rain5d = matrix(1:56, 120, 56, byrow = TRUE),
        maxT2 = matrix(1:56, 120, 56, byrow = TRUE),
        minT2 = matrix(1:56, 120, 56, byrow = TRUE),
        meanT2 = matrix(1:56, 120, 56, byrow = TRUE))

I know this seems like a simple problem but I’m a novice and am just not sure how to use a combination of for loops and internal indexing to remove columns. I’d rather learn how to do this efficiently, rather than doing it for each matrix individually and then creating the list.

Any help would be appreciated. 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-02T07:43:58+00:00Added an answer on June 2, 2026 at 7:43 am

    As is often the case, @DWin gets in early with an excellent answer. Here is an alternative that my simple mind finds easier to comprehend.

    You can use lapply to traverse your list, and then standard subsetting using the [ operator.

    Rather than using [ operator as a function (as @DWin suggests), I prefer writing an anonymous function inside lapply that looks exactly like the operation you would perform to transform a single element of your list (i.e. subset a single matrix):

    mls <- lapply(MatrixList, function(x)x[-c(17:40, 49:56), ])
    str(mls)
    
    List of 8
     $ maxT  : int [1:88, 1:56] 1 1 1 1 1 1 1 1 1 1 ...
     $ minT  : int [1:88, 1:56] 1 1 1 1 1 1 1 1 1 1 ...
     $ meanT : int [1:88, 1:56] 1 1 1 1 1 1 1 1 1 1 ...
     $ rain24: int [1:88, 1:56] 1 1 1 1 1 1 1 1 1 1 ...
     $ rain5d: int [1:88, 1:56] 1 1 1 1 1 1 1 1 1 1 ...
     $ maxT2 : int [1:88, 1:56] 1 1 1 1 1 1 1 1 1 1 ...
     $ minT2 : int [1:88, 1:56] 1 1 1 1 1 1 1 1 1 1 ...
     $ meanT2: int [1:88, 1:56] 1 1 1 1 1 1 1 1 1 1 ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using ApacheDS version 2.0.0-M3 (I not very familiar with how this works).
I am trying to compute using two loops. But I am not very familiar
I have not used jquery much yet and not very familiar with it. Trying
I'm not very familiar with regEx's and I'm trying to find a preg_match regex
I'm not very familiar with locale-specific conversions so I may be using the wrong
I am not very familiar with using XML in SQL Server and I have
I'm trying implement my project in Apache Struts 2 but I'm not very familiar
I am not very familiar with Hibernate Criteria, and apologize if this question is
I'm trying to probe the clientCaps object in Javascript (I'm not very familiar with
I am not very familiar with the way of creating a daemon in Python,

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.