[英]RccpArmadillo and RccpGSL not loading in RStudio in Windows
我有一個C ++函數:
#include <RcppArmadilloExtensions/sample.h>
using namespace Rcpp;
IntegerVector fnGender(int item, bool replace, NumericVector vSegPop,
IntegerVector vLevelsGender, NumericMatrix mGender) {
RNGScope scope;
IntegerVector ret = RcppArmadillo::sample(vLevelsGender, vSegPop(item),
replace, mGender.row(item)) ;
return ret;
}
我正在使用RccpArmadillo :: sample函數,而不是基R的sample()。
當我使用sourceCpp加載函數時,出現以下錯誤。
g++ -m64 -I"C:/Users/USER/DOCUME~1/R/R-31~1.1/include" -DNDEBUG -
I"C:/Users/USER/Documents/R/R-3.1.1/library/Rcpp/include" -
I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c Code.cpp -o Code.o
本着本季的精神,這是您的代碼,其中包含注釋中建議的兩個更改-在Windows上對我來說很好:
#include <RcppArmadilloExtensions/sample.h>
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;
// [[Rcpp::export]]
IntegerVector fnGender(int item, bool replace, NumericVector vSegPop,
IntegerVector vLevelsGender, NumericMatrix mGender) {
IntegerVector ret =
RcppArmadillo::sample(vLevelsGender, vSegPop(item),
replace, mGender.row(item)) ;
return ret;
}
我刪除了RNGScope scope;
因為這里使用的Rcpp構建框架會自動添加它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.