multmerge: Merge Multiple CSV Files

Description Usage Arguments Author(s) References Examples

Description

Combines multiple csv files into one data frame

Usage

1
multmerge(mypath, fileEncoding = "")

Arguments

mypath

the path where the csv files live. NOTE: only csv files can be in the path called

fileEncoding

This follows the same rules as the fileEncoding argument in read.csv. Added in because this was needed for a project

Author(s)

Chris Friedman

References

Tony Cookson's post, available at http://novicemetrics.blogspot.com/2011/04/merging-multiple-data-files-into-one.html

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
multmerge("./data/")
  this will return a data frame of all the csv files in the path in one frame.

## The function is currently defined as
function (mypath, fileEncoding)
{
  filenames=list.files(path=mypath, full.names=TRUE)
  datalist = lapply(filenames,
                    function(x){read.csv(file=x,
                                         header=T,
                                         fileEncoding = fileEncoding)})
  Reduce(function(x,y) {rbind(x,y)}, datalist)
  }

chris-s-friedman/Project_firestartr documentation built on May 13, 2019, 6:21 p.m.