[R] select .txt from .txt in a directory

Bert Gunter gunter.berton at gene.com
Fri Nov 8 18:50:43 CET 2013

1. Please don't post in HTML (see posting guide).

2. What do you mean by "extract?"

3. Your qiestion sounds very basic. Have you read "An Introduction to
R" or other online R tutorial? If not please do so before posting
further. All of R's file input functions allow you to specify the
directory path and/or filename, so if I understand you correctly, it's
just a matter of giving them to the appropriate function in some sort
of loop. e.g. something like

alldat <- lapply(filenameList, function(x)InputFunction(x,...))

4. If you need something fancier than is described in the tutorials,
consult the "R data Import/Export manual,"  please.

-- Bert

On Fri, Nov 8, 2013 at 9:33 AM, Zilefac Elvis <zilefacelvis at yahoo.com> wrote:
> Hi,
> I have 300 .txt files in a directory. Out of this 300, I need just 100 of the files.
> I have the names of the 100 .txt files which are also found in the 300 .txt files.
> How can I extract only the 100 .txt files from the 300 ,txt files?
> e.g given d1.txt, ds.txt, dx.txt, df.txt...d300.txt, how can I select only d1.txt and df.txt? Remember, I have 300 of such and want to extract 100 of them with names known.
> Thanks for your great help.
> Atem.
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list
> 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.


Bert Gunter
Genentech Nonclinical Biostatistics

(650) 467-7374

More information about the R-help mailing list