Skip to content

Instantly share code, notes, and snippets.

@emraher
Created December 3, 2014 06:20
Show Gist options
  • Save emraher/66f28e8384a1c92fd789 to your computer and use it in GitHub Desktop.
Save emraher/66f28e8384a1c92fd789 to your computer and use it in GitHub Desktop.
setwd("~/Dropbox/Tourism/Rdata")
rm(list=ls())
# Libraries ====================================================================
library("plyr")
library("reshape2")
# Start Merge ==================================================================
# See the following
# [1] http://goo.gl/9IojH8
# [2] http://goo.gl/IP1wa9
file_list <- list.files()
for (file in file_list){
# if the merged dataset doesn't exist, create it
if (!exists("dataset")){
dataset <- readRDS(file)
}
# if the merged dataset does exist, append to it
if (exists("dataset")){
temp_dataset <- readRDS(file)
dataset <- rbind(dataset, temp_dataset)
rm(temp_dataset)
}
}
# Save
saveRDS(dataset, file = "Merged.rds")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment