首先我知道这可能是一个Rcpp-Devel功能,但是当我尝试使用Firefox或Chrome进行订阅时,我在工作以太网上收到一个错误,即连接不安全,所以我现在要问这里。
所以我购买了Dirk的书,而且写得非常好。
我在这里遇到类似的错误 https://www.mail-archive.com/rcpp-devel%40lists.r-forge.r-project.org/msg08059.html
Sage<-testArm(set,labels,contrast,geneSets,var.equal=FALSE)
Calculating comparisons...Error in .Call("sigmaCalc", PACKAGE = "mySage") :
"sigmaCalc" not available for .Call() for package "mySage"
请注意,我的NameSpace有useDynLib(mySage),我可以成功运行compileAttributes和R CMD build(在外部目录中)并成功安装包。
当我尝试调用其中一个RcppExport.R函数时,我生成错误
这是我的一个Cpp代码
//[[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
#include <algorithm>
#include <vector>
#include <Rcpp.h>
#include <math.h>
#include <R.h>
using namespace arma;
using namespace Rcpp;
//'calculates the sd and mindof in order , names are assigned in R, as of now, there is no NA error checking. not very robust
//' @param SDs standard deviations from geneResults returned by makeComparison
//' @param DOFs degrees of freedom from geneResults returned by makeComparison
//' @param geneSets a set of genes for enrichment testing
//' @export
//' @return a List with SumSigma and MinDof
//[[Rcpp::export]]
List sigmaCalc( SEXP SDs, SEXP DOFs, SEXP geneSets) {
Rcpp::NumericVector SD(SDs);
Rcpp::NumericVector DOF(DOFs);
Rcpp::List geneSet(geneSets);
more code ....
这里的评论被创建并正确导出到R nameSpace 这是RcppExports.R
# This file was generated by Rcpp::compileAttributes
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#'calculates the sd and mindof in order , names are assigned in R, as of now, there is no NA error checking. not very robust
#' @param SDs standard deviations from geneResults returned by makeComparison
#' @param DOFs degrees of freedom from geneResults returned by makeComparison
#' @param geneSets a set of genes for enrichment testing
#' @export
#' @return a List with SumSigma and MinDof
sigmaCalc <- function(SDs, DOFs, geneSets) {
.Call('mySage_sigmaCalc', PACKAGE = 'mySage', SDs, DOFs, geneSets)
}
这是RcppExport.cpp
// This file was generated by Rcpp::compileAttributes
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#include <RcppArmadillo.h>
#include <Rcpp.h>
using namespace Rcpp;
// sigmaCalc
List sigmaCalc(SEXP SDs, SEXP DOFs, SEXP geneSets);
RcppExport SEXP mySage_sigmaCalc(SEXP SDsSEXP, SEXP DOFsSEXP, SEXP geneSetsSEXP) {
BEGIN_RCPP
Rcpp::RObject __result;
Rcpp::RNGScope __rngScope;
Rcpp::traits::input_parameter< SEXP >::type SDs(SDsSEXP);
Rcpp::traits::input_parameter< SEXP >::type DOFs(DOFsSEXP);
Rcpp::traits::input_parameter< SEXP >::type geneSets(geneSetsSEXP);
__result = Rcpp::wrap(sigmaCalc(SDs, DOFs, geneSets));
return __result;
END_RCPP
}
我不确定几件事,是否需要头文件?文本表明需要rcpp_hello_world.h,但是在读取RcppExport.cpp之后,export.cpp中包含了cpp函数声明,所以我不确定是否需要编写声明性头文件。还有networkBMA,wordcloud和pcaMethods都是Rcpp软件包而且它们不包含标题,那么只有接口API所需的标题是什么?
可能导致此错误的另一件事是我的函数参数是SEXP对象而不是Rcpp:NumericVectors ... / NumericMatrix,我应该编写cpp代码sigmaCalc来输入Rcpp类型,然后确保Export.cpp函数处理SEXP铸造?
谢谢。P.S。这是我在src /
中的Makevars## Use the R_HOME indirection to support installations of multiple R version
PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
PKG_CXXFLAGS=`$(R_HOME)/bin/Rscript -e "Rcpp:::CxxFlags()"`
我认为错误是我输入SEXP作为cpp函数的输入,这只在原型sourceCpp从C ++转到R时才需要,当打包时,RcppExports.cpp是两个系统之间的中介。 / p>
答案 0 :(得分:1)
帖子很长,看到结构很棘手。我建议你重新开始,然后再做其中一个
Rcpp.package.skeleton()
并研究该套餐,或从这些开始,重建它们。然后慢慢添加您的函数,运行compileAttributes()
并重建/重新安装。