c++ - 试图了解 .External() 是什么?
问题描述
我对 R 相当不熟悉,但希望用它来尝试使用特定的包。我从 R-Forge 安装了以下软件包:
install.packages("ecomodtools", repos = "https://R-Forge.R-project.org")
我收到以下错误:
仅提供源代码的软件包,可能需要编译 C/C++/Fortran:'ecomodtools'</p>
并了解到我需要“RTools”来安装它。所以我得到了 RTools,我能够安装这个包。
我在下面包含了一些可以复制粘贴的示例代码,但是当我运行此代码时,我收到关于 .External() 的错误,这是我想要理解的:
library(ecomodtools)
# 2D Gaussian dispersal function defined according to Clark et al. (1999)
# Used in the Monte Carlo integration
genexp.disp <- function(from, to, params)
{
r.sq <- (from[1] - to[1])^2 + (from[2] - to[2])^2
(1.0 / (pi * params[1]^2)) * exp(-(r.sq / params[1]^2))
}
# Monte Carlo integration settings
max.prob <- .Machine$double.eps^0.25
initial.step <- 10000
step.size <- 10000
max.runs <- 1000000
max.rel.var <- .Machine$double.eps^0.25
# Boundary condition
boundary <- "restricting"
# Alpha parameter setting
params <- c(1.0)
# Make a small grid (3 x 3) for testing purposes
x.coords <- seq(0.0, 3.0, 1.0)
y.coords <- seq(0.0, 3.0, 1.0)
test.grid <- MakeGridFromCoords(x.coords, y.coords)
# Calculate the transition matrices for each different approximation method
AA.mc <- LatticeTransitionProbs(
x1 = test.grid$x1, x2 = test.grid$x2, y1 = test.grid$y1, y2 = test.grid$y2,
func = genexp.disp, approx.method = "AA", boundary = boundary, max.prob = max.prob,
initial.step = initial.step, step.size = step.size, max.rel.var = max.rel.var, max.runs = max.runs, params = params)
错误:
.External("MakeGridFromCoords", x = as.double(x), y = as.double(y), 中的错误:
"MakeGridFromCoords" 不适用于包 "ecomodtools" 的 .External()
在源代码中,这个 .External() 函数似乎在所有函数中,我发现它的定义是“将 R 对象传递给已加载到 R 中的已编译 C/C++ 代码的函数”。
所以我希望有人能够对这里发生的事情给出不同的解释。我认为这个问题是我没有源 C/C++ 代码,所以也许 .External() 没有将信息发送给任何特别的东西。但同样,我对 R 很陌生,所以我不清楚发生了什么。
解决方案
推荐阅读
- c# - 使用依赖注入时在 .NET Core Web API 的另一个类中使用一个类及其功能
- firefox - 是否可以使用 Rexx、Reex2Nrx 和 NetRexx 编写 Mozilla Firefox 插件?
- angular - 错误 TS2552:使用 Angular 服务时找不到名称
- vba - 使用 VBA,如何确定 Word 文档中字段的范围?
- sql - 在 SQL 中对 2 列进行排名
- reactjs - 对象引用反应组件中的动态键的打字稿问题
- python - k-均值聚类顺序
- amazon-web-services - terraform 无法销毁 aws 上的废弃资源对象
- micronaut - 消息:未找到 JPA 配置的实体:包 [example.micronaut] 中的“默认”
- mongodb - 如何在 MongoDB 中按作业计算集合中数组内的真实布尔值的数量?