[R] extracting data files names with odd numbers from folder

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Mon Apr 4 07:56:00 CEST 2022


You need to learn regular expression patterns... there are lots of languages that use them, and tutorial websites that teach them to you. They are not the same as filename globbing patterns, and list.files uses regex because they are much more flexible.

Here is an example:

list.files( pattern = "[135]\\.csv$" )

On April 3, 2022 10:28:04 PM PDT, CHANCE CARTER <chance257 using comcast.net> wrote:
>I have a selection of data files saved as:
>File1.csv
>File2.csv
>File3.csv
>File4.csv
>.
>.
>.
>File100.csv
>
>I need to extract the odd numbered files.
>I have tried using the list.files function but I do not understand how to set pattern ="???" in order to extract the odd file names
>
>list.files(path, pattern= "????????",... )
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.



More information about the R-help mailing list