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))
y[[1]][i]
#[1] "10806" "xls"
This returns "10806" but also returns the file extension "xls".
And it could be made to loop through a vector of filenames.
Hope this helps,
Rui Barradas
Às 17:54 de 26/12/19, Thomas Subia escreveu:
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 extract parts common to both directories?
Thomas Subia
Statistician / Senior Quality Engineer
ASQ CQE
IMG Companies
225 Mountain Vista Parkway
Livermore, CA 94551
T. (925) 273-1106
F. (925) 273-1111
E. tsu...@imgprecision.com
Precision Manufacturing for Emerging Technologies
imgprecision.com
The contents of this message, together with any attachments, are intended only
for the use of the individual or entity to which they are addressed and may
contain information that is legally privileged, confidential and exempt from
disclosure. If you are not the intended recipient, you are hereby notified that
any dissemination, distribution, or copying of this message, or any attachment,
is strictly prohibited. If you have received this message in error, please
notify the original sender or IMG Companies, LLC at Tel: 925-273-1100
immediately by telephone or by return E-mail and delete this message, along
with any attachments, from your computer. Thank you.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.