如果利用endnote插入文獻(xiàn)時(shí),發(fā)現(xiàn)endnote 組中的文獻(xiàn)數(shù)量和word中不一致時(shí),word中更多,就會(huì)想第一:是不是endnote 組中重復(fù)插入,但是很好對(duì)比,就直接刪除了,而word中還沒刪除,插重復(fù)了。第二:endnote 組中少了word中插入的文獻(xiàn),忘記將文獻(xiàn)添加進(jìn)入endnote 組。而人工看,費(fèi)時(shí)費(fèi)力。

image.png
因此,可以將word中的參考文獻(xiàn)部分存為.txt文件,endnote 組根據(jù)作者排序后,輸出.txt文件。然后進(jìn)入R
#將數(shù)據(jù)讀入r ,每一個(gè)引用最后都是以換行符結(jié)尾,因此讀入的表格是一列
word <- read.table("/word.txt",sep ="\t")
endnote <- read.table("/endnote.txt",sep ="\t")
#去掉行號(hào)
word$V1 <- gsub("\\[.*?]\\","",word$V1)
endnote $V1 <- gsub("\\[.*?]\\","",endnote $V1)
#判斷是否有重復(fù)行
du <- word[duplicated(word),]
#根據(jù), 空格等將1列分為多列
out <- strsplit(as.character(word $V1),' ')
word <- do.call(rbind,out)
out <- strsplit(as.character(endnote $V1),' ')
endnote <- do.call(rbind,out)
#轉(zhuǎn)為數(shù)據(jù)框
word <- as.data.frame(word)
endnote <- as.data.frame(endnote)
#根據(jù)第一個(gè)作者的名字判斷不在endbote中的條目
word_out <- word[! word $V2 %in% endnote $V2,]
#根據(jù)第一個(gè)作者的名字判斷重復(fù)
du_1 <- word[duplicated(word$V2),]
du_2 <- word[duplicated(endnote $V2),]
最后我的問題出現(xiàn)在endnote中少了一個(gè),重新將其歸入endnote,就對(duì)得上了。