Function to go to a particular part of the code

Asked

Viewed 60 times

0

There is some function in the R so that the given condition it jumps to a certain part of the code. I am implementing an audit model, but at certain points it needs external files that are sent only at the end of the year, but I would like to review the other items before that. The code I thought would be something similar to the one below, but not the one to insert inside the if.

if(length(list.files(pattern = "RREO"))==0){#Proximo item da auditoria}
  • 2

    I think you should consider changing the logic of the code. if(o ficheiro existe){processar ficheiro} else {seguir em frente}.

1 answer

0

You can use the function next. See fictitious example:

v <- LETTERS[1:6]
for ( i in v) {

   if (i == "D") {
      next
   }
   print(i)
}
[1] "A" 
[1] "B" 
[1] "C" 
[1] "E" 
[1] "F"

In your case the v would be the files, and you would make the condition based on whether the file exists or not (ie if it returns NULL on import).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.