I have a folder with a number of subdirectories with numerous files of different types. I only need to select files that have the following extension *.txt and *.shp. I have tried to use pattern with & and | combination but it does not seem to work. the | operator only selects the file format that was written last (in the code below, it only selects the *.shp files and not the *.txt)
filelist <- list.files(path = ".",pattern = '*.txt$ | *.shp$', recursive = TRUE, ignore.case = TRUE, include.dirs = TRUE, full.names = TRUE)