R动态导入库

时间:2016-01-13 15:54:16

标签: r

我正在尝试创建一个函数,该函数将加载库(如果存在),或尝试安装它(如果不存在)。我遇到的问题是如何动态使用library函数。 R使得这很难,因为library函数不仅接受字符串。

例如,加载h2o:

library('h2o') ## This works
library(h2o) ## This also works...

但是,如果我有一个名为h2o的变量?

,该怎么办?
h2o <- 'plyr'
library(h2o) ## imports the h2o package, not plyr

如何使用变量动态加载包?

1 个答案:

答案 0 :(得分:3)

使用?library选项进行h20 <- "plyr"; library(h20, character.only=TRUE); sessionInfo(); 来电。见#import <XCTest/XCTest.h> #import "CertificateManager.h" @interface UITests : XCTestCase @end -(void)testWelcomeScreen { //put the app into initial state [[CertificateManager sharedInstance] resetApplication]; //... proceed with test }

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_CertificateManager", referenced from:
      objc-class-ref in UITests.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)