I am trying to find a way in R
to copy certain binary files of interest to another folder. I am selecting those files based of a key
. A sample of which is shown below. The problem is that the numbers in the key has three
decimal places where as the files have four
.
For instance how can I tell R
that if it finds 43.093_-110.531
in a file name then it should copy that file to another folder.
The file names are some thing like this
data_43.09375_-110.53125
data_43.09375_-110.59375
search key
43.093_-110.531
43.093_-110.469
43.093_-110.406
43.156_-110.594
43.156_-110.531
43.156_-110.469
43.156_-110.406
43.156_-110.344
43.156_-110.281
43.218_-110.844
43.218_-110.781
43.218_-110.719
43.218_-110.656
43.218_-110.594
43.218_-110.531
CodePudding user response:
We may use substr
to extract and then do %in%
files[ substr(files, 5, 22) %in% key]