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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:11:31+00:00 2026-05-31T08:11:31+00:00

I am trying to save the data from a loop of logical tests. So

  • 0

I am trying to save the data from a loop of logical tests.

So I have the following data:

T1 <- matrix(seq(from=100000, to=6600000,length.out=676),26,26) # a matrix of 26X26 - here with illustrive values

minmax <- seq(from=1,to=49,by=1) # creates a sequence
Fstep <- 6569141.82/minmax       # define a vector from 0 to 6569141.82 with 49 divisions
F <- rev(round(Fstep,0))         # round the vector values and re order them
F

I have runned the following loop

for (i in 1:49) {
  print(T1 > F[i]) # I used print to see the results in the screen
}

This loop returns me 49 matrices filled in with logical values (True or false). Each matrix is the comparison of T1 against each of the 49 positions F[i] (F[1], …., F[49])

I need to have the values in those matrices for further using as adjacency matrices for network plots. However when I can’t neither assign those logical values to an matrix, neither save them in csv values using “write.matrix”.

So, I need to have 49 – matrices “W” filled in with logical values (T or F). I already got those values by the loop above but I can’t get it as an object or as collection of csv. files.

I tried

W<-matrix(0,26,26) #create an empty matrix to assign the logical arguments
for (i in 1:49){
  W[i] <- T1>F[i] # I used print to see the results in the screen
}

which returns the following warning

Warning messages:
1: In W[i] <- (T1 > F[i]) :
  number of items to replace is not a multiple of replacement length

I also tried a different setting in which all the matrices I compare have the same dimensions.

create.M <- function(F){ #  a function to transform  each position F[i] into a 26X26 matrix
  for (i in 1:49) {
    matrix(F[i],26,26)
  }
}

Loop.T1 <- function(T1){ #  a function to replicate T1(49 times)
  for ( i in 1:49) {
    T1
  }
}

and compared the two outputs

Loop.T1(T1)>create.M(F)

which returns

logical(0)
  • 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-31T08:11:33+00:00Added an answer on May 31, 2026 at 8:11 am

    Store each boolean matrix as an item in a list:

    result <- vector("list",49)
    for (i in 1:49)
    {
       result[[i]] <- T1>F[i] # I used print to see the results in the screen
    }
    
    #Print the first matrix on screen
    result[[1]]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to save my data from a view that was loaded on
I'm trying to save the returned data from HTTP request into a variable. The
I am trying to save data into the same table several times from the
I'm trying to save some lookup table data out to a YAML file so
I'm having hard time trying to figure out how to auto-save user data in
I am trying to work out how to parallelize some code from data mining
I'm trying to save data from the database into a csv file. My problem
Hi, I am trying to save data using web services, jquery and json. From
I'm trying to save the data retrieved from the database into a .json. This
Update mysql with $_POST data from while loop I'm trying to get this round

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.