I want to distribute the names of files in two different vectors. If they exist, they should go to existing\_files and if not, they should go to missing\_files.

```
existing_files <- ""
missing_files <- ""

f1 <- function(file_name){
  if (any(file_name == vector_of_file_names)) {
    existing_files <- append(existing_files, file_name)
  } else {
    missing_files <- append(missing_files, file_name)
  }
}

f1("file1")

```

Executing "file1" does not work and i don't get any warning or error. Why is that? If i remove "existing\_files <-" and "missing\_files <-" in the function, i would get the correct result in the console. But i need it stored in the global environment.

A bit more information on what i am trying to solve here:

I am scanning the folder i am working with for file names i have stored in "vector\_of\_file\_names". I just wanna know, if all the files i need are in that folder or not. I do that with list.files, which gives me all the files. Then i compare those files to "vector\_of\_file\_names". The result is what is seen in my question. I want two vectors that list the files (that i want in that folder) according to their existence in that folder.