Git Product home page Git Product logo

find_lit_db_duplicates's Introduction

Find duplicate entries in a literature database extract using R by (fuzzy) matching on Title

This script (available in find_duplicates.R) can be used to find titles in an extract from a literature database (such as PubMed) and identify any entries that are either duplicated exactly (i.e. the same title is included more than once) or likely to be duplicated (the match is not exact, but close). In the example file (csv-longtermco-set.csv), there is one exact match and two inexact matches (i.e. one duplicated paper, one patient comment and one erratum).

The results of the script can then be used to manually check and clean database extracts when conducting systematic reviews.

#Author: Dr Will Parry 
#Web: http://willparry.net

#Load packages
pkgs <- c('data.table', 'purrr', 'stringr', 'stringdist')
sapply(pkgs, require, character.only = TRUE)

#Read database extract
db_extract <- 'csv-longtermco-set.csv' #example extract from pubmed
#NB: must have a Title field on which to match

#Read extract into data table and add a string for title matching
db_table <- fread(db_extract) %>%
  .[, match_string := toupper(str_remove_all(Title, '[:punct:]| '))]
#string is made from Title field, made upper case, with all punctuation and spaces removed

#Create table of 'distances' between pairs of match_string values using {stringdist} package
dist_table <- db_table[['match_string']] %>% #using just the vector of match_strings 
  combn(2) %>% t() %>% #get all combinations and transpose result to long format
  data.table() %>% #make into a data table
  setnames(c('V1', 'V2'), c('title1', 'title2')) %>% #rename columns
  .[, dist := stringdist(title1, title2)] %>% #add string distance metric
  .[order(dist)] #order in increasing distance (top of table will be most similar)

View(head(dist_table)) #view the most similar results

#Distance of zero is an exact match
#In the example, there is:
# - one exact match (duplicated paper)
# - one patient comment on a listed paper
# - one erratum for a listed paper

find_lit_db_duplicates's People

Contributors

drwillparry avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.