Reputation: 1092
lets say i run the function list.files()
I will get a character vector looking like this:
tst<-c("Test.Uncx4.1_2281.2_deBruijn.txt", "Test.Vax1_3499.1_deBruijn.txt",
"Test.Vax2_3500.1_deBruijn.txt", "Test.Vsx1_1728.1_deBruijn.txt",
"Train.Alx3_3418.2_deBruijn.txt", "Train.Alx4_1744.1_deBruijn.txt",
"Train.Arx_1738.2_deBruijn.txt", "Train.Bapx1_2343.1_deBruijn.txt",
"Train.Barhl1_2590.2_deBruijn.txt", "Train.Barhl2_3868.1_deBruijn.txt"
)
The problem I’m experiencing is when using the parameter pattern
from list.files()
Like this: list.files(dirs[1], pattern = "^[Train]",ignore.case=F)
I still get all the files back while i`m expecting to get only the Train files. like this:
c("Train.Alx3_3418.2_deBruijn.txt", "Train.Alx4_1744.1_deBruijn.txt",
"Train.Arx_1738.2_deBruijn.txt", "Train.Bapx1_2343.1_deBruijn.txt",
"Train.Barhl1_2590.2_deBruijn.txt", "Train.Barhl2_3868.1_deBruijn.txt")
How is this possible or what did i do wrong?
Upvotes: 0
Views: 1988
Reputation: 49033
What you want is :
list.files(dirs[1], pattern = "^Train",ignore.case=F)
With the pattern you provided, with the brackets, you were filtering for files whose names begin with T, r, a, i or n.
Upvotes: 3