【问题标题】:Deduping Unique Pairs, on Data stored Consecutively, using RecordLinkage使用 RecordLinkage 对连续存储的数据进行重复数据删除
【发布时间】:2019-11-14 00:14:37
【问题描述】:

我正在使用recordlinkeage 来查找重复项。我正在使用几种不同的搜索来识别对。我想合并我的成对集,以删除两种方法之间的重复项。我想拥有所有独特的对,它们在getPairs(y)getPairs(z) 中。作为最终产品,我想要一个包含所有独特组合的 data.frame。

library(RecordLinkage) 

# Making some synthetic data
x <- rbind( mtcars , mtcars[2,])
x$name <- rownames( x )
x$nrid <- sample( 1:1000000 , nrow( x))

y = compare.dedup(
    x,
    blockfld=c("gear", "carb", "am", "name") ,
    phonetic = "name" ,
    phonfun = soundex) 

z = compare.dedup(
    x,
    blockfld=c( "am", "name") ,
    phonetic = "name" ,
    phonfun = soundex) 

# I know that I can see the details of my pairs
summary(y)
y <- getPairs(y)
z <- getPairs(z)

【问题讨论】:

    标签: r record-linkage


    【解决方案1】:

    我认为这可能只是使用dplyr::full_join的问题:

    library(RecordLinkage) 
    x <- rbind(mtcars , mtcars[2, ])
    x$name <- rownames(x)
    x$nrid <- sample(1:1000000, nrow(x))
    y = compare.dedup(
      x, blockfld = c("gear", "carb", "am", "name") ,
      phonetic = "name", phonfun = soundex
    ) 
    z = compare.dedup(
      x, blockfld = c("am", "name"),
      phonetic = "name", phonfun = soundex
    ) 
    
    ## Check the list components of y, z: safe to merge
    all(names(y$pairs) == names(z$pairs))
    all(y$frequencies == z$frequencies)
    
    ## Remove duplicates while combining pairs from both: key line
    z$data <- dplyr::full_join(y$data, z$data)
    getPairs(z)
    

    如果有多个要合并的东西,您可以使用Reduce 合并到一个列表中。 如果这不是你想要的,请告诉我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-02
      • 2012-12-12
      • 1970-01-01
      • 2021-12-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多