使用R包中的.Fortran()错误提示功能不可用 [英] Using .Fortran() from R package with error saying function not available

查看:163
本文介绍了使用R包中的.Fortran()错误提示功能不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了以下代码:

library(quantreg) # to load the package
library(foreign)  # to load the package

.Fortran("rqfn", PACKAGE = "quantreg")

但出现以下错误:

Error in .Fortran("rqfn", PACKAGE = "quantreg") : 
"rqfn" not available for .Fortran() for package "quantreg"

我已经安装了Rtools.但这并不能解决问题. 我还检查了与系统路径有关的问题(例如在此站点中: https://github.com/stan-dev/rstan/wiki/Install-Rtools-for-Windows ),但这没有问题. 有人可以帮我吗?非常感谢.

I have installed Rtools. But it does not solve the problem. I also checked the issues concerning system paths (as in this site: https://github.com/stan-dev/rstan/wiki/Install-Rtools-for-Windows), but there is no problem about that. Could anyone give me a hand? Thank you very much.

推荐答案

您可以构建自己的库:

  • 下载rqfn.frqfnb.f. stepy方法需要后者.
  • 致电R CMD SHLIB rqfn.f rqfnb.f
  • 使用如下函数:

  • Download rqfn.f and rqfnb.f. The latter is needed for stepy method.
  • Call R CMD SHLIB rqfn.f rqfnb.f
  • use the function like this:

data(stackloss)
x <- stack.x
y <- stack.loss
n <- length(y)
p <- ncol(x)
dyn.load(paste0("rqfn", .Platform$dynlib.ext))

.Fortran("rqfn",
     as.integer(n),
     as.integer(p),
     a = as.double(t(as.matrix(x))),
     c = as.double(y),
     rhs = double(p),
     d = double(n),
     beta = as.double(0.99995),
     eps = as.double(1e-6),
     tau = as.double(0.5),
     wn = double(10 * n),
     wp = double((p + 3) * p),
     aa = double(p * p),
     it.count = integer(2),
     info = integer(1))

这篇关于使用R包中的.Fortran()错误提示功能不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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