Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 204847

list.files on R with a pattern from a list

$
0
0

So, I have this folder with more than 200 files. Each file is named as orto_[name]_bom.shp

[name] is the variable

I want to list only the 7 files (on the folder) that is on the vector below

name=c('ananindeua','belém','benevides','castanhal','marituba','santa bárbara do pará','santa izabel do pará')

My code is

files <- list.files(path = './data/regions/sector/',
                  pattern = paste0("orto_", name, "_bom.shp", full.names = TRUE)

But it is not returning all the seven files. It only returns the [ananindeua] one.

I wonder how code it.


Viewing all articles
Browse latest Browse all 204847

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>