gugl58
6/21/2018 - 4:31 PM

make.bibfile

Make bibfile for all loaded libraries

packagesToCite<- search()
packagesToCite<- ifelse(grepl("package:", packagesToCite), packagesToCite, NA)
packagesToCite<- sub("package:(*.)", "\\1", packagesToCite)
packagesToCite<- packagesToCite[!is.na(packagesToCite)]



citation.bibtex.list <- lapply(packagesToCite, function(x) toBibtex(citation(x)))
sink("R-bibfile.bib")
i<-1
for(listElementX in citation.bibtex.list){
	if(length(strsplit(sub(",", "", listElementX[1]), "\\{"))<2){
		listElementX[1] <- sub(",", paste0(packagesToCite[i], ","), listElementX[1]) 
		i <- i+1
	}
	print(listElementX)
}
sink()