Re: [R] Checking for similar file names in two different directories

2019-12-26 Thread Bert Gunter
AHA! -- I think I now see what you mean. My previous suggestion was almost useless as it assumes you already know what the "common" parts are ... but you don't. However, if it is the filename parts at the end are separated by spaces from the preceding part of the filename, i.e. like "stuff xx

Re: [R] Checking for similar file names in two different directories

2019-12-26 Thread Richard O'Keefe
I think you had better start by defining what you mean by "similar". Examples are good, but not enough. On Fri, 27 Dec 2019 at 06:54, Thomas Subia wrote: > > Colleagues, > > I have two locations where my data resides. > One folder is for data taken under treatment A > One folder is for data taken

Re: [R] Checking for similar file names in two different directories

2019-12-26 Thread Rui Barradas
Hello, I am not sure if the following code is what you need but maybe you can get some inspiration from it. x <- c("G:\ 0020-49785 10806.xls", "Q:\ 301864 4519 10806.xls") y <- strsplit(x, split = "[^[:alnum:]]+") eq <- sapply(y[[1]], `==`, y[[2]]) i <- apply(eq, 1, function(e) Reduce(`|`, e

Re: [R] Checking for similar file names in two different directories

2019-12-26 Thread Bert Gunter
?list.files and ?regexp Warning: following obviously untested: Gfiles <- list.files("G:", pattern = ".*10806\\.xls$") should then give you a vector of character names of the files you want to feed to read.xls() or whatever function exists in the favored package is for reading Excel files these d

[R] Checking for similar file names in two different directories

2019-12-26 Thread Thomas Subia
Colleagues, I have two locations where my data resides. One folder is for data taken under treatment A One folder is for data taken under treatment B "G:\ 0020-49785 10806.xls" "Q:\ 301864 4519 10806.xls" Here the 10806 is the part which is common to both directories. Is there a way to have R e