Hi, looks like the list.files() method was the key to my problem. With
that, I was able to just loop through the "files" variable and get the
file names to load
Thanks for your help.
Mark
On Jan 31, 2010, at 8:23 PM, jim holtman wrote:
Something like the following might work. YOu can use 'choose.dir()'
to get the directory:
files <- list.files(path=yourDir)
result <- do.call(rbind, lapply(files, read.csv))
On Sun, Jan 31, 2010 at 9:10 PM, Mark Altaweel <maltaw...@anl.gov>
wrote:
Hi,
I am trying to load csv type data from a folder. However, rather than
syntax that simply loads one file at a time I was wondering if there
is a method that loads all data from a specific folder.
For instance, I have the following data files in a folder
nebraskaStats:
10-1-2009_10-7-2009.txt
10-2-2009_10-8-2009.txt
10-3-2009_10-9-2009.txt
....etc. (245 total files in folder)
Each file has the following format:
Data1-5,Data 2-6,Data 3-7,...
1,2,3,...
Although the comma separated format is consistent file to file, the
name of the columns differ in many of the files.
What I want to do is simply load all that data by pointing to the
folder rather than specific file names.
I know this syntax: state.frame<-read.table("/nebraskaStats/",
header=T, sep=",") does not seem to read data from a folder but
rather
it is intended to load specific files. I could write a loop that
iterates the number of the files (e.g., N-S-2009_N-T-2009, whereby
N,S, and T are iterated in the loop); however, this also seems
cumbersome. Anyway, is there a simple method that just loads all the
data in a folder rather than have to call out each specific file?
Thanks in advance. This has been a great board and I appreciate all
the past help.
Mark
[[alternative HTML version deleted]]
______________________________________________
R-help@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.
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
______________________________________________
R-help@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.