[R] Any existing functions for reading and extracting data from path names?

From: Ista Zahn <izahn_at_psych.rochester.edu>
Date: Fri, 11 Mar 2011 11:52:33 -0500


Hi helpeRs,

I have inherited a set of data files that use the file system as a sort of poor man's database, i.e., the data files are nested in directories that indicate which city they come from. For example:

dir.create("deleteme")
for(i in paste("deleteme", c("New York", "Los Angeles"), sep="/")) {

    dir.create(i)
    for(j in paste("data", 1:2, ".csv", sep="")) {

        write.csv(data.frame(x=1:10), file=paste(i, j, sep="/"))     }
}

list.files("deleteme", recursive=TRUE)

What I want to end up with is

  x city wave
  1 New York 1
  1 Los Angeles 1
  1 New York 2
  1 Los Angeles 2

I've started writting a simple function to do this, but it seems like a common situation and I'm wondering if there are any packages or functions that might make this easier.

Thanks!
Ista

-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

______________________________________________
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 Fri 11 Mar 2011 - 17:12:13 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 Sat 12 Mar 2011 - 00:50:20 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