How to deal with this and NOT?

I am trying to return the file name from list.files, but there are two equally named files. filename.csv filename_review.csv

I want to put each file name in my own list. Doing this for filename_review.csv easy, as it has unique things in it, but how to sift another? I need grep(".csv", list.files()) without returning filename_review.csv .

+4
source share
3 answers

Found this ... fileListBig[!(fileListBig %in% fileListSmall)] and it works.

-2
source

The display of all files in the working directory with the extension csv, but not ending in the overview, can be performed:

 setdiff(list.files(pattern='.csv$'), list.files(pattern='review.csv$')) 
+11
source

Another option is grep for what you don't want, and then return everything else.

 csvs <- list.files(patt='.csv$') csvs[!grepl('_', csvs) 
+3
source

Source: https://habr.com/ru/post/1369037/


All Articles