Hello, On Tue, Aug 13, 2019 at 01:59:56PM -0400, Christopher W Ryan wrote: > But this assumes that all files have column names in their first row. In > this case, some don't. Any advice how to handle it so that those with > column names and those without are read in and combined properly?
It obvously depends on the data, but here is an other approach (which I hope has not been suggested yet): 1. For each file, read only the first row (and keep track of file => first row), 2. Make counts of dinstinct first rows. If data is sufficely not identical on first rows, the highest count will indicate that its a header, so mark this as the header, 3. Reread files, since there is some form of mapping kept in step 1, one knows if header should be TRUE or FALSE, and fix headers after reading with headers set to FALSE. This can of course miserably fail if the set of saved files do not have enough ones with headers included. HTH in your case, but it's definitely not generic. -- BenoƮt
signature.asc
Description: PGP signature
______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.