Hi everybody I have a large number of Excel speadsheets that I want to merge into one R dataframe to process. I can read them one by one with read.xls but I really need a function to read a whole directory at once and merge the columns with the same name into a single dataframe.
here is what I have thus far (on Mac OS X 10.5.2. for R 2.8.0): # Define the directory where the data is path="/Users/home/mydata/" # Make a list of the filenames (they are all .xls so no need for a regular expression seekig out ones ending in .xls ) files=list.files(path="/Users/home/mydata/") # Read them into a list called data data=tapply(paste(path,files,sep=""),files[1:length(files)],read.xls) This gives the data in a list. What I want is a dataframe. I can turn it into a matrix with as.matrix() but that only has one column which is more or less the same as a list. I have tried to merge different parts of the list : mdata=date.frame(merge(data[[1]],data[[2]])) but that gives an empty data frame (with the correct variable names). Even if it worked I need a way to do that with a large number of file (i.e. not manualy). I also tried to use lapply with merge as function but that didn't work either Does anyone have any ideas? I would much appreciate it regards Chrisitiaan [[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.