Re: [R] Reading tables using a truncated name

From: hadley wickham <h.wickham_at_gmail.com>
Date: Tue, 11 Nov 2008 14:05:59 -0600

Which can be simplified to:

paths <- dir(path = filePath, pattern = "^test_", full = T) lapply(paths, read.csv)

Hadley

On Tue, Nov 11, 2008 at 2:01 PM, <chibco_at_gmail.com> wrote:
> Hi all,
>
> Thanks everyone for your advice. They have been helpful.
>
> Just for the record, I am using ...
>
> lapply(dir(path = filePath, pattern = "^test_"), function(x){read.table(file
> = paste(filePath, x, sep = ""), sep = ",", header = TRUE) } )
>
> to load the files
>
> kind regards
>
> Chibisi
>
> On Tue, Nov 11, 2008 at 5:13 PM, Henrique Dallazuanna <wwwhsd_at_gmail.com>wrote:
>
>> Try this:
>>
>> sapply(dir(patt="^test_"), read.table, sep = ";", header = TRUE)
>>
>> On Tue, Nov 11, 2008 at 3:06 PM, <chibco_at_gmail.com> wrote:
>>
>>> Dear all,
>>>
>>> I am trying to read a bunch of csv files using read.table() that are named
>>> "test_xxxxxx.csv" where "xxxxxx" has no particular pattern. Is there a way
>>> of reading all the files by specifying a truncated file name e.g. "test_"
>>> with some wild card characters, or would I have to laboriously create some
>>> vector with the "xxxxxx" names and iterate or lapply() over it?
>>>
>>> Kind regards
>>>
>>> Chibisi
>>>
>>> [[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.
>>>
>>
>>
>>
>> --
>> Henrique Dallazuanna
>> Curitiba-Paraná-Brasil
>> 25° 25' 40" S 49° 16' 22" O
>>
>
> [[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.
>
>

-- 
http://had.co.nz/

______________________________________________
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 Tue 11 Nov 2008 - 20:08:23 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 Tue 11 Nov 2008 - 20:30:24 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