2018.7.6作业
merge使用方法:
merge(book, borrow13, by = c("book_barcode","title"),all=T)
book,borrow13:是文件名
book_barcode,title是要合并的两项,放在合并后的结果的最前面。
举个栗子:
使用merge方法把两个数据集合成一个,然后再基于这个最全的大数据集进行联合分析
代码如下:
#book.txt与borrow2013.txt合并book_barcode,title两个内容
book <- read.table(file = "f:/data/book.txt", header=T, sep = "\t", quote = "",comment.char = "", stringsAsFactors =F)
borrow13 <- read.table(file = "f:/data/borrow2013.txt", header=T, sep = "\t", comment.char="",quote = "", stringsAsFactors =F)
book2 = merge(book, borrow13, by = c("book_barcode","title"),all=T)
head(book2,10)
结果: