Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 将部分文件名与完整文件名匹配_R_File Copying_Name Matching - Fatal编程技术网

R 将部分文件名与完整文件名匹配

R 将部分文件名与完整文件名匹配,r,file-copying,name-matching,R,File Copying,Name Matching,我有以下方式命名的文件列表 csv_files<-list.files(path, pattern =‘.csv’) csv\u文件下面的代码未经测试,因为我的磁盘上没有这些文件,也没有新的路径。 我会按照 csv_files <- c("1001_2017_01_02#19_30_24.csv", "1002_2018_03_01#20_30_54.csv") dat <- data.frame(prefix = c("1001_2017_01_02", "1002_201

我有以下方式命名的文件列表

csv_files<-list.files(path, pattern =‘.csv’)

csv\u文件下面的代码未经测试,因为我的磁盘上没有这些文件,也没有新的路径。
我会按照

csv_files <- c("1001_2017_01_02#19_30_24.csv", "1002_2018_03_01#20_30_54.csv")
dat <- data.frame(prefix = c("1001_2017_01_02", "1002_2018_03_01"))

lapply(dat$prefix, function(x) {
    fl <- csv_files[grep(x, csv_files)]
    file.copy(from = fl, to = newpath)
})
csv\u文件