[R] reading in all files of a certain type
Dan Davison
davison at stats.ox.ac.uk
Tue May 18 04:09:39 CEST 2010
jim holtman <jholtman at gmail.com> writes:
> try:
>
> pattern="*result*\\.csv$"
Just for the record, that's not quite correct. The * doesn't behave like
in a shell glob. Instead, * says "0 or more copies of the previous
character". So the above pattern picks up resul.csv, which I don't think
was intended.
I don't know what a * is defined to do when it is the first character of
a regexp, but I believe it should be avoided.
Dan
>
> On Mon, May 17, 2010 at 9:06 PM, Dimitri Liakhovitski
> <dimitri.liakhovitski at gmail.com> wrote:
>> Thanks again - and one follow-up question.
>> When I do do.call(rbind, lapply(dir(patt = "\\.csv$"), read.csv))
>> What is the right way to speicify (probably under "patt") that I only
>> need to grab those .csv files that contain a certain string, e.g.,
>> "result"?
>> I tried a couple of things, like patt= "\\.csv$" & pat = "result" -
>> but it does not seem to work
>> Thanks a lot!
>> Dimitri
>>
>>
>>
>> On Wed, May 12, 2010 at 6:16 PM, Dimitri Liakhovitski
>> <dimitri.liakhovitski at gmail.com> wrote:
>>> Thanks a lot, Henrique, will try!
>>> Dimitri
>>>
>>> On Wed, May 12, 2010 at 3:41 PM, Henrique Dallazuanna <wwwhsd at gmail.com> wrote:
>>>> Try this:
>>>>
>>>> do.call(rbind, lapply(dir(patt = "\\.csv$"), read.csv))
>>>>
>>>> On Wed, May 12, 2010 at 4:32 PM, Dimitri Liakhovitski
>>>> <dimitri.liakhovitski at gmail.com> wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>> I am wondering if it's possible to read in all files of a certain type
>>>>> - without specifying their names.
>>>>> For example, I have 10 .csv files in my working directory.
>>>>> I would like to read them in and bind them all together. I was
>>>>> thinking of writing a loop, read in all files, and then bind them.
>>>>> Is it possible?
>>>>>
>>>>> Thanks a lot!
>>>>>
>>>>> --
>>>>> Dimitri Liakhovitski
>>>>> Ninah Consulting
>>>>> www.ninah.com
>>>>>
>>>>> ______________________________________________
>>>>> 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.
>>>>
>>>>
>>>>
>>>> --
>>>> Henrique Dallazuanna
>>>> Curitiba-Paraná-Brasil
>>>> 25° 25' 40" S 49° 16' 22" O
>>>>
>>>
>>>
>>>
>>> --
>>> Dimitri Liakhovitski
>>> Ninah Consulting
>>> www.ninah.com
>>>
>>
>>
>>
>> --
>> Dimitri Liakhovitski
>> Ninah Consulting
>> www.ninah.com
>>
>> ______________________________________________
>> 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.
>>
More information about the R-help
mailing list