CHANCE CARTER
2022-Apr-04 05:28 UTC
[R] extracting data files names with odd numbers from folder
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]]
Jeff Newmiller
2022-Apr-04 05:56 UTC
[R] extracting data files names with odd numbers from folder
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 at 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 at 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.