R语言与数据可视化-180706

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)

结果:
这里写图片描述

猜你喜欢

转载自blog.csdn.net/lijia111111/article/details/80935843
今日推荐