Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在R中的RecordLink包中使用函数RLBigDataLinkage记录链接数据帧_R - Fatal编程技术网

在R中的RecordLink包中使用函数RLBigDataLinkage记录链接数据帧

在R中的RecordLink包中使用函数RLBigDataLinkage记录链接数据帧,r,R,我想链接两个使用不同数字键但类似字符串的数据帧。具体而言,一个数据帧使用数字键GVKEY和公司名称CONML > head(temp.compustat[order(temp.compustat$CONML, decreasing = T), ]) GVKEY CONML 225994 13023 ZZZZ Best Co Inc 211017 11696 Zytrex Corp 213816 11951 Zytec System

我想链接两个使用不同数字键但类似字符串的数据帧。具体而言,一个数据帧使用数字键
GVKEY
和公司名称
CONML

> head(temp.compustat[order(temp.compustat$CONML, decreasing = T), ])
        GVKEY             CONML
225994  13023  ZZZZ Best Co Inc
211017  11696       Zytrex Corp
213816  11951 Zytec Systems Inc
309886  29163        Zytec Corp
373950 129441         Zynex Inc
383184 145228  ZymoGenetics Inc
> dim(temp.compustat)
[1] 31354     2
另一个数据框使用不同的数字键
companyid
和公司名称
company
,这可能与第一个数据库中的
CONML
略有不同

> head(temp.dealscan[ order(temp.dealscan$company, decreasing = T), ])
      companyid            company
70473     18192 Zytec Corp 
32025     16969 Zynaxis Inc
19714     92271 ZYGO Teraoptix Inc
80473     13185 Zygo Corp 
1901      24303 Zycon Corp SDN Bhd 
33993     21219 Zycon Corp

> dim(temp.dealscan)
[1] 85818     2
(我是反向排序的,因为DealScan数据库在某些条目的开头有空格和*)。似乎包
RecordLinkage
中的函数
RLBigDataLinkage
就是解决方案,但我甚至无法让无监督链接工作。这是我的错误

> library(RecordLinkage)
> rpairs <- RLBigDataLinkage(dataset1 = temp.compustat, dataset2 = temp.dealscan, exclude = 1, strcmp = 2, strcmpfun = "levenshtein")
> result <- epiClassify(rpairs, threshold.upper = 0.5)
Error in if (max <= min) stop("must have max > min") : 
  missing value where TRUE/FALSE needed
In addition: Warning message:
In nData1 * nData2 : NAs produced by integer overflow
>库(记录链接)

>rpairs结果(1000个条目)。谢谢

这是由于软件包代码中的一个错误造成的,该错误现已修复。固定版本将在R-Forge的项目现场提供(https://r-forge.r-project.org/projects/recordlinkage)可能到明天早上。请注意,它取决于data.table软件包的1.5.4版,该软件包目前在CRAN上不可用,但在R-Forge上可用(https://r-forge.r-project.org/projects/datatable/).

+1表示问题。关于前导空格,我发现gdata包中的trim函数很有用。