Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
require(RQuantLib)失败_R_Quantlib - Fatal编程技术网

require(RQuantLib)失败

require(RQuantLib)失败,r,quantlib,R,Quantlib,我正在尝试加载RQuantLib,但出现以下错误: > require(RQuantLib) Loading required package: RQuantLib Error : .onLoad failed in loadNamespace() for 'RQuantLib', details: call: if (is.character(qc) && nchar(qc) > 1) { error: missing value where TRUE/FA

我正在尝试加载RQuantLib,但出现以下错误:

> require(RQuantLib)
Loading required package: RQuantLib
Error : .onLoad failed in loadNamespace() for 'RQuantLib', details:
  call: if (is.character(qc) && nchar(qc) > 1) {
  error: missing value where TRUE/FALSE needed
In addition: Warning message:
running command 'bash -c 'type -p quantlib-config' 2>/dev/null' had status 1 
> require('RQuantLib', lib.loc = "C:/Users/dealmer/Library/R/3.1/library/RQuantLib/libs")
Loading required package: RQuantLib
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  no library trees found in 'lib.loc'
一般来说,我对编程相当陌生,所以我不确定这意味着什么。我在Mac OS Maverick环境中工作,我下载了RQuantLib的最新版本(0.3.12),并且“R软件包安装程序”说它已经安装。(我从终端使用“R CMD INSTALL RQuantLib”安装了RQuantLib,因为使用R中的INSTALL.packages()无法工作-它给我一个错误,说QuantLib没有配置,尽管它在终端中运行正常。)我从R控制台运行R。QuantLib运行良好,Rcpp也是如此

我检查了RQuantLib文件夹中的“名称空间”文档,它显示:

import(methods)
importFrom(Rcpp, Rcpp.plugin.maker)

useDynLib(RQuantLib)

exportPattern("*.default")

export(
       ##--arrays.R
       "oldEuropeanOptionArrays",
       "EuropeanOptionArrays",
       "plotOptionSurface",
       ##--asian.R
       "AsianOption",
       ##--bermudan.R
       "BermudanSwaption",
       "summary.G2Analytic",
       "summary.HWAnalytic",
       "summary.HWTree",
       "summary.BKTree",
       ##--bond.R
       "ZeroCouponBond",
       "ZeroPriceByYield",
       "ZeroYield",
       "FixedRateBond",
       "FixedRateBondYield",
       "FixedRateBondPriceByYield",
       "FloatingRateBond",
       "ConvertibleZeroCouponBond",
       "ConvertibleFixedCouponBond",
       "ConvertibleFloatingCouponBond",
       "CallableBond",
       "FittedBondCurve",
       ##--calendars.R
       "isBusinessDay", "businessDay",
       "isHoliday",
       "isWeekend",
       "isEndOfMonth",
       "getEndOfMonth", "endOfMonth",
       "adjust",
       "advance",
       "businessDaysBetween",
       "getHolidayList", "holidayList",
       "setCalendarContext",
       ##--dayCounter.R
       "dayCount",
       "yearFraction",
       "setEvaluationDate",
       ##--discount.R
       "DiscountCurve",
       "plot.DiscountCurve",
       ##--implied.R
       "EuropeanOptionImpliedVolatility",
       "AmericanOptionImpliedVolatility",
       "BinaryOptionImpliedVolatility",
       ##--option.R
       "EuropeanOption",
       "AmericanOption",
       "AmericanOption.default",
       "BinaryOption",
       "BarrierOption"
       )

S3method("plot", "Option")
S3method("print", "Option")
S3method("summary", "Option")

S3method("plot", "Bond")
S3method("print", "Bond")
S3method("summary", "Bond")
如果我试图指定终端在要求安装RQuantLib时写入的路径,则会出现以下错误:

> require(RQuantLib)
Loading required package: RQuantLib
Error : .onLoad failed in loadNamespace() for 'RQuantLib', details:
  call: if (is.character(qc) && nchar(qc) > 1) {
  error: missing value where TRUE/FALSE needed
In addition: Warning message:
running command 'bash -c 'type -p quantlib-config' 2>/dev/null' had status 1 
> require('RQuantLib', lib.loc = "C:/Users/dealmer/Library/R/3.1/library/RQuantLib/libs")
Loading required package: RQuantLib
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  no library trees found in 'lib.loc'
那么,我是否需要将一些东西从那里移动到其他R库所在的位置?(在其他R库文件夹所在的文件夹中已经有一个名为“RQuantLib”的文件夹,例如,我在那里找到了名称空间文档)终端给我的路径在Finder窗口中我无法遵循,因为它没有显示“library”文件夹,我不知道如何让它这样做。)

这就是.libpath()给我的:

> .libPaths()
[1] "/Users/dealmer/Library/R/3.1/library"                          
[2] "/Library/Frameworks/R.framework/Versions/3.1/Resources/library"
R库位于[2]中

我试过谷歌搜索,但找不到任何有用的东西。任何帮助都将不胜感激。非常感谢。
-Dom

我也遇到了同样的问题,经过几个小时的努力,我设法使用了一些不太严格的东西,但它确实有效! 在评估
系统(“bash-c'type-pquantlib-config')时,R似乎遇到了一些问题。
安装完QuantLib后,在终端中键入命令
bash-c'type-p QuantLib config'
将为我们提供QuantLib配置的路径,该路径适用于我
/opt/local/bin/QuantLib config

因此,我回到了RQuantLib(版本0.4.0)的源文件文件夹,并将文件
R/inline.R
中的qc替换为:


qc我认为问题在于,在Linux上,
$PATH
中有
quantlib config

edd@max:~$ quantlib-config --help
Usage: quantlib-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] \
                       [--libs] [--cflags]
edd@max:~$ quantlib-config --version
1.4
edd@max:~$ 

我没有OSX设备,所以我需要像你这样的人来帮助我更好地配置设置。如果您将
quantlib config
复制(或软链接)到您的路径中(例如
/usr/local/bin
),或者调整
$path
以包含它所在的目录,那么它应该可以工作。

正如@dirk eddelbuettel提到的,您可以检查
/opt/local/bin
是否在您的环境变量中。(从R运行
系统(“printenv”)
)。如果不是,那么您需要添加它。可能是-