3
나는이 C++ 코드가 있습니다Rcpp : 오류 : 요청 유형과 호환되지
#include <R.h>
#include <Rcpp.h>
using namespace Rcpp;
extern "C" {
SEXP gensampleRcpp2(Function rlawfunc, SEXP n) {
Rcpp::RNGScope __rngScope;
return Rcpp::List::create(Rcpp::Named("sample") = rlawfunc(n),
Rcpp::Named("law.name") = " ",
Rcpp::Named("law.pars") = R_NilValue);
}
RcppExport SEXP gensampleRcpp(SEXP rlawfuncSEXP, SEXP nSEXP) {
BEGIN_RCPP
Function rlawfunc = Rcpp::as<Function >(rlawfuncSEXP);
IntegerVector n = Rcpp::as<IntegerVector >(nSEXP);
SEXP __result = gensampleRcpp2(rlawfunc, n);
return Rcpp::wrap(__result);
END_RCPP
}
SEXP compquantRcpp2(IntegerVector n, IntegerVector M, Function Rlaw) {
int i;
GetRNGstate();
for (i=1;i<=M[0];i++) {
List resultsample = gensampleRcpp2(Rlaw, n);
NumericVector mysample = Rcpp::as<NumericVector >(resultsample["sample"]);
}
PutRNGstate();
return Rcpp::List::create(Rcpp::Named("law.pars") = "");
}
RcppExport SEXP compquantRcpp(SEXP nSEXP, SEXP MSEXP, SEXP RlawSEXP) {
BEGIN_RCPP
IntegerVector n = Rcpp::as<IntegerVector >(nSEXP);
IntegerVector M = Rcpp::as<IntegerVector >(MSEXP);
Function Rlaw = Rcpp::as<Function >(RlawSEXP);
SEXP __result = compquantRcpp2(n, M, Rlaw);
return Rcpp::wrap(__result);
END_RCPP
}
}
이 R 코드 : (패키지라고 힘
compquant <- function(n=50,M=10^3,Rlaw=rnorm) {
out <- .Call("compquantRcpp",n=as.integer(n),M=as.integer(M),as.function(Rlaw),PACKAGE="PoweR")
return(out)
}
을 사실 위의 코드는 단순화 내 코드의 목적을 이해하려고 시도하지 마라.) 나는 (Linux 및 R 버전 3.1.0에서) 내 패키지를 컴파일 할 때 콘솔에서 다음 R 명령을 실행 : 오류 : 요청 유형
를와 호환되지 나는 다음과 같은 오류가require(PoweR)
compquant()
을
문제의 원인과 해결 방법에 대해 알고 계십니까?
감사합니다.
R 3.1.1, x86_64-w64-mingw32/x64 (64 비트)에서 RStudio 0.98.1056을 사용하여 빌드 한 'compquant()'는 하나의 요소 인'law.pars'가있는 목록을 반환합니다. 단일 빈 요소가있는 문자 벡터. – jbaums
이것은 rcpp-devel에게 크로스 게시되었으며 거기에서 뒤따라 왔습니다. –
jbaums에 회신하려면 다음과 같은 명령을 발행 할 수 있습니다. 오류는 때때로 (i in 1 : 100) compquant()에 발생하기 때문에 –