How to list only certain files in R? -
i have thousands of different files (having same extension .img
) in folder called data
. if use :
dir<- list.files ("c:\\users\\data", "*.img", full.names = true)
it list files have in folder data
.
what need list files named as:
file_yyyymmdd_data.img (in yyyymmdd varies 10 years)
any idea or hint appreciated!
try this
files.new = list.files(directory.path, recursive = true, pattern=".img")
where, "directory.path" path directory containing files need read
edited
to more appropriate
files.new = list.files(directory.path, recursive = true, pattern="file_[0-9]{8}_data[.]img$")
Comments
Post a Comment