如何判断你在 R 中使用了哪些包 [英] How to tell what packages you have used in R

查看:24
本文介绍了如何判断你在 R 中使用了哪些包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很长的 R 脚本,其中包含许多 if 语句和异常情况.正如我一直在做的那样,如果我一直在导入和测试库,并且还没有真正很好地记录它们.问题是,如果我从全新安装运行它,我不确定脚本将运行哪些语句,因此需要哪些库.

I have a very long R script with many if statements and exception cases. As i've been going, if been importing and testing libraries as I've gone and haven't really documented them very well. The problem is that if I run this from a clean installation, i'm not sure which statements the script will run, and so which libraries will be needed.

我的问题是:是否有任何 R 函数来测试脚本中正在使用哪些库?

My question is: Is there any R function to test which libraries are being used in a script?

我没有使用所有已安装的库,所以 print(sessionInfo()) 不会有用,但我只想开始带有 install.packages 函数的脚本

I have not used all of the libraries that have been installed so print(sessionInfo()) won't be useful but and I just want to start the script with an install.packages function

推荐答案

我从 NCmisc (install.packages("NCmisc")) 对此非常有帮助:

I found the list.functions.in.file() function from NCmisc (install.packages("NCmisc")) quite helpful for this:

list.functions.in.file(filename, alphabetic = TRUE)

有关更多信息,请参阅此链接:https://rdrr.io/cran/NCmisc/man/list.functions.in.file.html

For more info see this link: https://rdrr.io/cran/NCmisc/man/list.functions.in.file.html

这篇关于如何判断你在 R 中使用了哪些包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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