[R] get a vector with filenames with a certain extension in a folder
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Fri Jul 17 08:24:47 CEST 2009
milton ruser wrote:
> Hi there,
>
> try this:
>
> setwd("/home/mcr")
> dir(path=".", pattern=".txt$")
>
> OR
>
> dir(path="/home/mcr/.", pattern=".txt$")
>
> $ means finished with ".txt"
A word of warning. The pattern is a regular expression, so the above
means that the name ends with an arbitrary character followed by "txt".
pattern=glob2rx("*.txt")
is more likely to do what you want.
> good luck,
>
> milton
> brazil=toronto
>
> On Fri, Jul 17, 2009 at 12:08 AM, torpedo fisken <torpedofisken at gmail.com>wrote:
>
>> Hi
>> I got a script that works on file with the extension ".qed" that are
>> al located in a folder '~/works/'
>>
>> Is there are R function that will fetch all the filenames from the works
>> subdir,
>> similar to
>> 'ls ~/works/*.qed'
>>
>>
>> Thanks in advance
>>
>> ______________________________________________
>> 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.
>>
>
> [[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.
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list