【发布时间】:2024-04-25 19:15:02
【问题描述】:
我正在尝试根据由另一个文件夹中的文件组成的列表从“rawimages”文件夹中选择文件。将有 1000 个这样的文件,我在下面包含了一个作为示例。唯一的区别是 RAW 图像没有“_hc”,但 rawimages 文件夹中有其他文件。见下文:
ValidateImages <- list.files("C:/Users/JS22/Desktop/Validated")
#example of validated image name: Pia1.2016-10-07.2056+N2009_hc.tif
#Gives list as character value
ToselectfromRAW <- list.files("C:/Users/JS22/Desktop/Raw", pattern = ??ValidateImages??)
#example of raw image name: Pia1.2016-10-07.2056+N2009.tif
file.copy(from = c(ToselectfromRAW), to = "C:/Users/JS22/Desktop/Training_Set", overwrite = TRUE)
#move the selected images to the desired location
我知道它与 list.files 函数的 'pattern =' 部分有关,但我不确定是什么。如果有帮助,我可以将列表更改为列表:
ValidateImages<- as.list(list.files("C:/Users/JS22/Desktop/Validated", all.files = TRUE))
任何帮助都会很重要!
(用于随机森林训练集仅供参考)
【问题讨论】: