Re: [R] R: selecting and excluding files through a pattern

From: Phil Spector <spector_at_stat.berkeley.edu>
Date: Thu, 10 Jun 2010 15:43:37 -0700 (PDT)

Here's one possibility:

allfiles = list.files()
csvfiles = list.files(pattern='csv')
allfiles[!allfiles %in% csvfiles]

On Fri, 11 Jun 2010, mauede_at_alice.it wrote:

> Actually this pattern will select the files whose name contains "csv".
> Whereas I'd like to exscude them.
> Maura
>
> -----Messaggio originale-----
> Da: Jorge Ivan Velez [mailto:jorgeivanvelez_at_gmail.com]
> Inviato: gio 10/06/2010 17.30
> A: mauede_at_alice.it
> Cc: r-help_at_stat.math.ethz.ch
> Oggetto: Re: [R] selecting and excluding files through a pattern
>
> Hi Maura,
>
> Try list.files(pattern = 'csv')
>
> HTH,
> Jorge
>
>
> On Thu, Jun 10, 2010 at 11:24 AM, <> wrote:
>
>> I have the following files list:
>>
>>> list.files()
>> [1] "Prostate-Cancer_cvs_Dir"
>> [2] "Prostate_Cancer-miRNAs&Genes.Pathway.xml"
>> [3] "Prostate_Cancer_Pathways-miRNAs-GeneTargets-Dir"
>> [4] "Prostate_Cancer_Pathways-miRNAs-GeneTargets-Dir.zip"
>> [5] "Prostate-miRNAs.OrganTargets.txt"
>> [6] "Prostate_Organ-miRNAs-GenesTargets-Dir"
>> [7] "Prostate_Organ-miRNAs-GenesTargets-Dir.zip"
>> [8] "Prostate_Organ-miRNAs-Targets.xml"
>> [9] "Prostatic_Neoplasm-miRNAs.DiseaseTargets.csv-KO"
>> [10] "Prostatic_Neoplasm-miRNAs.DiseaseTargets.txt"
>> [11] "Prostatic_Neoplasms-miRNAs-GeneTargets-Dir"
>> [12] "Prostatic_Neoplasms-miRNAs-GeneTargets-Dir.zip"
>> [13] "Prostatic_Neoplasms-miRNAs.xml"
>>
>> I'd like to find the pattern expression which selects only the directories
>> excluding the one whose
>> pathname contains "csv".
>> I tried:
>>> list.files(pattern="Prostate*Dir")
>> But I do not know how to exclude the names containing the string "csv" at
>> the same time.
>>
>> Thank you for any help,
>> Maura
>>
>>
>>
>>
>> ;
>>
>>
>> tutti i telefonini TIM!
>>
>>
>> [[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.
>>
>
>
>
>
> tutti i telefonini TIM!
>
>
> [[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.
>



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. Received on Thu 10 Jun 2010 - 22:45:42 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 11 Jun 2010 - 00:40:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive