一次加载多个包 [英] Load multiple packages at once
本文介绍了一次加载多个包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在不一遍又一遍地重新输入 require 命令的情况下一次加载一堆包?我尝试了三种方法,但都崩溃了.
How can I load a bunch of packages at once with out retyping the require command over and over? I've tried three approaches all of which crash and burn.
基本上,我想为将加载它们的函数提供一个包名称向量.
Basically, I want to supply a vector of package names to a function that will load them.
x<-c("plyr", "psych", "tm")
require(x)
lapply(x, require)
do.call("require", x)
推荐答案
你提议的函数的几个排列确实有效——但前提是你将 character.only
参数指定为 TRUE代码>.快速示例:
Several permutations of your proposed functions do work -- but only if you specify the character.only
argument to be TRUE
. Quick example:
lapply(x, require, character.only = TRUE)
这篇关于一次加载多个包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文