R中的屏蔽函数列表

R中的屏蔽函数列表

本文介绍了R中的屏蔽函数列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了很多包,我知道有些功能被屏蔽了,因为它们存在于几个不同的包中.有没有办法获取重复函数(或屏蔽函数)的列表?

I use a lot of packages and I know some functions are masked because they exist in several different packages.Is there a way to get the list of duplicate functions (or masked functions?)

理想的情况是有一个重复函数列表,并为每个函数提供它所在的包列表.

The ideal would be to have a list of duplicate function and for each of them, the list of packages in which it exists.

推荐答案

in R base:

in R base:

 conflicts(detail=TRUE)

并找到包含一个版本的环境列表

And to find the list of environments that contain a version of

getAnywhere(x = "functionA")

注意:getAnywhere 还可以找到 导出的函数.因此不会产生冲突.

Note: getAnywhere also finds the functions which are not exported. and that are hence not creating conflicts.

使用以下方法可以获得更好(更简单)的结果:

A better (simpler) result could be obtained using:

x = "functionA"
names(which(sapply(search(), FUN = function(env) exists(x, env, inherits = FALSE, mode = "function"))))

这篇关于R中的屏蔽函数列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 13:14