R:在安装基础包时找不到()的功能

时间:2017-08-23 08:20:08

标签: r tidyverse

我的脚本中的以下行

gather(key = var, value = val,  which(names(somevar) == "somestring"):length(somevar))

抛出错误

 Error in which(names(somevar) == "somestring") : 
     could not find function "which"

当我在控制台中编写which时,输出仍然如下......

> which
function (x, arr.ind = FALSE, useNames = TRUE) 
{
    wh <- .Internal(which(x))
    if (arr.ind && !is.null(d <- dim(x))) 
        arrayInd(wh, d, dimnames(x), useNames = useNames)
    else wh
}
<bytecode: 0x0000000006c6e258>
<environment: namespace:base>

我应该在哪里了解如何解决问题?

PS。 base(包含which函数)包已安装。 extrafont 脚本中加载了toolstidyrdplyrreadxl个包。 R版本为3.4.1,系统为Win8

@akrun在评论

中提出的

UPD。代码

somevar <- data.frame(v1 = 1:5, somestring = 6:10, v3 = 11:15, v4 = 16:20);
somevar %>% gather(key = var, value = val, which(names(somevar) == "somestring"):length(somevar)) %>% head(2);

引发同样的错误...

Error in which(names(somevar) == "somestring") : 
  could not find function "which"

0 个答案:

没有答案