I have the following R code to load xts timeseries from multiple files and merge them in a single xts matrix:
load.files = function(dates, filenames) {
  for( i in 1:length(dates) ) {
  # load and merge each xts block
  ts.set = load.single.file(dates[i], filenames[i])
  if( i == 1 )
    ts.all = ts.set
  else
    ts.all = rbind(ts.all, ts.set)
}
return(ts.all)
Is there a way to
- Avoid the if/else statement required to initialize the very first ts.set?
- Avoid the for loop altogether?
 
    