I have several .txt
files in a directory (filedir
) which start with the following strings:
files= c('sasmin_somedata.txt','sasmax_somedata.txt','sas_somedata.txt')
s=c("sasmin","sasmax","sas")
I would like to use s
to list the three files in files
.
I tried the following code:
p <- glob2rx(paste0(s, filedir))
final <- list.files(filedir, p,full. Names=TRUE)
However,I keep getting duplicates of sasmin
, sasmax
because my current glob2rx
implementation uses ‘sas’ as wildcard and cannot different ‘sas
‘ from ‘sasmin
‘ or ‘sasmax
‘.