A function to merger xlsx files by a same variable.

Share:

Description

This is a function that can be used to merger xlsx file using identified variables.

Usage

1
MergerXLSX(original_file, addin_file, mergeID)

Arguments

original_file

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.

addin_file

The file that need to be merged. It should be "xlsx" file and saved in the same working folder.

mergeID

The merger variable name in both files. The variable name should be same in two files.

Details

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.

Value

Return data are all original data with addin variables.

Author(s)

Xiaorui (Jeremy) Zhu

References

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.

Examples

1
2
3
# file1 <- "C:/data.xlsx"
# file2 <- "C:/data2.xlsx"
# merged <- MergerXLSX(file1, file2, mergeID)