I am trying to import and merge a set of csv files using the following code, but it doesn\'t seem to be passing the by=c(\"X\",\"Y\") argument to the merge function. Any recomme
merge
doesn't accept more than 2 data.frames, so you can't pass it a larger list using do.call
:
do.call(merge, list(iris, iris, iris))
#Error in fix.by(by.x, x) :
# 'by' must specify one or more columns as numbers, names or logical
Use Reduce
instead:
Reduce(function(x, y) merge(x, y, by="Species"), list(iris, iris, iris))
#works
do.call
accepts a list of all arguments, so try:
my.df <- do.call("merge",append(lapply(csvfiles, read.csv, header = TRUE), list(by=c("date","fx_code")) )