A function to merger xlsx files by a same variable.
This is a function that can be used to merger xlsx file using identified variables.
MergerXLSX(original_file, addin_file, mergeID)
The name of original file. This file contains all original data. It should be a "xlsx" file and saved in the same working folder. This input must be a character string of file name if it is saved in working directory, or it should include saving path of file.
The file that need to be merged. It should be "xlsx" file and saved in the same working folder.
The merger variable name in both files. The variable name should be same in two files.
This function need three parameters. First is name of the original file that contains original data. Second is name of file that need to be merged. Third is the identifiable variable name that in both files.
Return data are all original data with addin variables.
Xiaorui (Jeremy) Zhu
Author's Github https://github.com/XiaoruiZhu. If you have trouble with rJava or xlsx, please check http://stackoverflow.com/questions/7019912/using-the-rjava-package-on-win7-64-bit-with-r for further information to fix it.
1 2 3
# file1 <- "C:/data.xlsx" # file2 <- "C:/data2.xlsx" # merged <- MergerXLSX(file1, file2, mergeID)