如何处理“参数”无可比拟!= FALSE'未使用(尚未)“? [英] How to handle "argument 'incomparables != FALSE' is not used (yet)"?

查看:380
本文介绍了如何处理“参数”无可比拟!= FALSE'未使用(尚未)“?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查data.frame()中的一行是否与现有行重复。如前所述,这里一种方法可能是使用重复的功能。但是,如果我使用该函数,我会收到以下错误:

I want to check if a row in data.frame() is a duplicate of an existing row. As already pointed out here one way might to be to use the duplicate function. However, if I'm using the function I get the following error:

Error: argument 'incomparables != FALSE' is not used (yet)

在一个相当老的邮件中有人指出,这实际上是一个R(关于 here 的更多信息)。我的data.frame()如下所示:

In a quite old mail somebody pointed out that this is actually a bug in R (more information over here). My data.frame() looks like this:

data.frame(val1=int,val2=int,val3=int,val4=float);

我想知道这个问题是什么,因为我的data.frame,as

I'm wondering what the issue actually is since there seems to be no "NA" value in my data.frame, as

?duplicate

指出。这可能是一个非常愚蠢的问题,但我对R很新,对于这个问题的任何提示都很高兴!

points out. This is maybe a very stupid question, but I'm quite new to R and would be glad for any tips regarding this issue!

提前感谢
迈克尔

Thanks in advance, Michael

PS:我提供了一个例子,建议

P.S.: I've provided an example as suggested

table <- NULL;

foo <- function(n, d, nh, v){
  newEntry <- data.frame(node_i=n, node_j=nh, dst=d, phi=v);

  if(length(table != 0)){
    if(!duplicated(table, newEntry)){
      add(n, nh, d, v);
    }else{
      print("it is a duplicate!")    
    }
  }else{
    add(n, nh, d, v);
  }
}

add <- function(n, d, nh, v){
  rbind(table, data.frame(node_i=n, node_j=nh, dst=d, phi=v)) ->> table;
}

bar <- function(){
  foo(23,42,5,4.0);
  print(table);
  foo(22,42,5,4.0);  
  print(table);
  foo(23,42,5,4.0);
  print(table);
}

然而,这似乎并不是duplicate()的一个问题。如果我尝试添加另一行叹息,我会收到相同的错误。

However, this seems not to be a problem with duplicate() at all. I get the same error if I try to add another row sigh.

推荐答案

code>复制函数与 match_df plyr ,该问题应该解决。

If you replaceduplicated function with match_df from plyr, the issue should be resolved.

library(plyr) # for match_df
table <- NULL;

foo <- function(n, d, nh, v){
  newEntry <- data.frame(node_i=n, node_j=nh, dst=d, phi=v);

  if(length(table != 0)){
    if(nrow(plyr::match_df(table, newEntry))){
      add(n, nh, d, v);
    }else{
      print("it is a duplicate!")    
    }
  }else{
    add(n, nh, d, v);
  }
}

add <- function(n, d, nh, v){
  rbind(table, data.frame(node_i=n, node_j=nh, dst=d, phi=v)) ->> table;
}

bar <- function(){
  foo(23,42,5,4.0);
  print(table);
  foo(22,42,5,4.0);  
  print(table);
  foo(23,42,5,4.0);
  print(table);
}



输出



Output

> bar()
node_i node_j dst phi
1     23     42   5   4
Matching on: node_i, node_j, dst, phi
[1] "it is a duplicate!"
node_i node_j dst phi
1     23     42   5   4
Matching on: node_i, node_j, dst, phi
[1] "it is a duplicate!"
node_i node_j dst phi
1     23     42   5   4
> table
node_i node_j dst phi
1     23     42   5   4                  

这篇关于如何处理“参数”无可比拟!= FALSE'未使用(尚未)“?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆