devtools :: check使用cpp_object_initializer失败

问题描述 投票:-1回答:1

我运行devtools::test它的工作原理:

$ RScript -e "devtools::test()"
...
OK:       24

devtools::check未通过测试:

$ RScript -e "devtools::check()"
...
> test_check("package")
Error in cpp_object_initializer(.self, .refClassDef, ...) : 
  could not find function "cpp_object_initializer"
Stan model 'bayes_logit' does not contain samples.
── 1. Error: Mixture of Dirichlet Processes stick-breaking works and returns (@t
'data' must be of a vector type, was 'NULL'
1: mdp_logit_mvn_stickbreaking(n_samp = n_samp, mix_mean = NULL, mix_cov = NULL, posterior_sample = stan_sample, 
       prior_sample_size = 1, dataset = german, tol = 1e-08) at testthat/test_stick_breaking.R:35
2: MASS::mvrnorm(n = n_samp, mu = mix_mean, Sigma = mix_cov)
3: eigen(Sigma, symmetric = TRUE)
4: unname(as.matrix(x))
5: as.matrix(x)
6: as.matrix.default(x)
7: array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), NULL) else NULL)

我该如何解决?

r
1个回答
0
投票

这是由于加载和附加之间的差异。我从this GitHub issue那里得到了解决方案。

NAMESPACE中添加这个以告诉R在哪里可以找到cpp_object_initialiser

Depends:
    Rcpp

这有效,但它会给你一个注释。要避免注释,请在使用Rstan调用的函数周围添加Roxygen导出:

#' @importFrom Rcpp cpp_object_initializer
function_name <- function(...) {...}
© www.soinside.com 2019 - 2024. All rights reserved.