R比较两个文件中的名字是否重名

b1.csv
name
zhangsan
lisi

aa.csv
name
zhangsan
wangsi


check_names <- function(file) {
  require(readr)
  check_file <- readr::read_delim(file=file,delim=" ",
                                  col_names = c("name"))
  aa <- readr::read_delim(file="/home/work/blue/aa.csv",delim=" ",
                               col_names = c("name"))
  ret <- intersect(aa, check_file)
  ret
}

file = "/home/work/blue/b1.csv"
abc <- check_names(file)
abc

 

posted @ 2020-11-13 16:49  船长博客  阅读(182)  评论(0编辑  收藏  举报
永远相信美好的事情即将发生!