I'm trying to get some files with a very simple regular expression using list.files
.
files <- list.files('C:/filepath/...', pattern = ('split*.csv'), full.names=TRUE)
I have some files in that specific folder:
split1.csv
split2.csv
split3.csv
...
This code is supposed to work, according to a lot of examples I saw. But when I run it with the pattern pattern = ('split*.csv')
I get an empty 'list' back.
However, when I run it with pattern = ('split1.csv'),
it matches with the file split1.csv
.
When I run it with the pattern pattern = ('*.csv')
, it also works fine: It matches all split files, but of course also the other csv files in the folder.
So, the problem is not that the files do not exist in this folder. The filepath is correct, but with pattern = ('split*.csv')
, it does not match the above split files. This should be, given the many examples I have seen of this.
Could it be true that something has changed about this function? Does anyone know how to filter for the right files?
Working with R Version 3.6.1.