0

I need help stepping through a second loop in R when a test fails in my first loop. Here's the logic:

  1. to start use config_list[1] from list
  2. then download file path_list[1] from list
  3. check if file passes test,
  4. if so, download path_list[1 + 1] file from list and go back to step 3
  5. if not, change config to next in list and go back to step 2 for failed file

Here's how far I've gotten:

path_list <- list("path1", "path2", "path3")
config_list <- list("a", "b", "c")


for (con in config_list) {
  con[1] # set initial config
  for (val in path_list) {
    print(paste(val, "downloaded")) # download file
    if (val == "path2"){ # check if file passes some test
      con[1 + 1] # if above test fails change to con[1 + 1]
      print(paste(val, "downloaded")) # download file again with new config ???
    }
    print(val)
  }
}
2
  • Could you modify the example to include how you would like to use config_list? At the moment, it is not included at all so folks trying to help are likely a bit confused about how to integrate it. Also, nothing here is an actual list, which is a specific data structure in R: path_list and config_list are both vectors. In your data, are they in vector or list format? This would have implications on how to approach this issue. Good luck! Commented Dec 29, 2022 at 16:32
  • @jpsmith thanks for the feedback, hopefully its more clear now. I can covert the lists to vectors if it makes for a cleaner solution. I want the loop to move to the new config[1+1] until there's another failed test and then move forward 1 on the list again. Commented Dec 29, 2022 at 16:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.