There are at least a couple of "gotchas" that should be noted, however:
1. The files = data.frames can only be rbind-ed (?is this the past tense of rbind?) if the columns have the same names as well as numbers. 2. The corresponding column classes must be the same for all data.frames. You may not get errors if this is not true, but silent coercions may end up changing things from what you expect. Editorial Comment: I find that both these issues often cause problems in reading in spreadsheets due to a)typos and inconsistencies in column names and character columns (especially with spaces and caps)-- which by default become factors -- and stray characters (e.g., commas or "$" in American numeric and financial columns). It's very easy for such little problems to slip into Excel spreadsheets unless the creators are very fastidious, which most of us aren't. My subjective estimate is that >50% -- and probably closer to 90% -- of "uncurated" spreadsheets (as opposed to e.g. structured databases) contain such problems. Hopefully these issues will not bedevil you. Cheers, Bert Gunter Genentech -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Wednesday, December 26, 2007 1:37 PM To: [email protected]; Kondamani, Arjun (GMI - NY Corporate Bonds) Subject: Re: [R] Rbind-ing a list into one item >From: "Kondamani, Arjun (GMI - NY Corporate Bonds)" <[EMAIL PROTECTED]> >Date: 2007/12/26 Wed PM 03:23:51 CST >To: [email protected] >Subject: [R] Rbind-ing a list into one item try do.call(rbind,res) >Hi, > >I am doing the following: > >1. I have a list of files.. Files1=list.files("some >directory",pattern="some pattern") >2. I define a list as res=vector("list", length(files1)) >3. I read all the files into this list: res=lapply(files1, read.csv) > >I now want to rowbind all the items in the list into one big mass (all >files have same number of columns). I tried lapply(res, rbind) but that >did not work. Suggestions? >-------------------------------------------------------- > >This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing. >-------------------------------------------------------- > > [[alternative HTML version deleted]] > >______________________________________________ >[email protected] 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. ______________________________________________ [email protected] 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. ______________________________________________ [email protected] 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.

