Dear all
I am using a Windows 7 system, R studio 0.99.467, R x64 3.3.1 and R tools 34.
I have been trying to run sourceCpp("reglinRcpp.cpp") in my R studio and got
the following error message. It seems clear that the issue is that the Rcpp.h
file cannot be found. So I have tried to run set
PKG_CXXFLAGS='-I/H:/R/win-library/3.3/Rcpp/include' in the windows command
window (see attached screenshot). However, this does not solve the issue. Could
anyone advise me what I should do? Thanks a lot in advance!
Kind regards
Xinda
c:/Rtools/mingw_64/bin/g++ -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG
-I"//INFPWFS1014.ad.unsw.edu.au/Staff081z3271570/R/win-library/3.3/Rcpp/include"
-I"C:/Users/z3271570/Desktop/rsrcpp"
-I"d:/Compiler/gcc-4.9.3/local330/include" -std=c++11 -O2 -Wall
-mtune=core2 -c reglinRcpp.cpp -o reglinRcpp.o
reglinRcpp.cpp:1:18: fatal error: Rcpp.h: No such file or directory
#include <Rcpp.h>
^
compilation terminated.
make: *** [reglinRcpp.o] Error 1
Warning message:
running command 'make -f "C:/PROGRA~1/R/R-33~1.1/etc/x64/Makeconf" -f
"C:/PROGRA~1/R/R-33~1.1/share/make/winshlib.mk"
SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)'
SHLIB="sourceCpp_17.dll" WIN=64 TCLBIN=64 OBJECTS="reglinRcpp.o"' had status 2
Error in sourceCpp("reglinRcpp.cpp") :
Error 1 occurred building shared library.
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
NumericVector Cfunc(NumericVector xvec, IntegerVector M, NumericVector beta0,
NumericVector alpha) {
int d = 0, m, i, n = xvec.size();
NumericVector yvec(n);
double meanxy = 0.0, meanx = 0.0, meany = 0.0, meanx2 = 0.0, meany2 = 0.0;
double thresh, num = 0.0, denom = 0.0, tobs, beta1hat, beta0hat, sighat,
sighatbeta1hat;
thresh = R::qt(1.0 - alpha[0] / 2.0, (double)(n - 2), 1, 0);
for (i = 0; i< n; i++) {
meanx = meanx + xvec[i];
meanx2 = meanx2 + R_pow(xvec[i], 2.0);
}
meanx = meanx / (double)n;
meanx2 = meanx2 / (double)n;
GetRNGstate();
for (m = 0; m < M[0]; m++) {
meany = 0;
meany2 = 0;
meanxy = 0;
for (i = 0; i < n; i++) {
yvec[i] = beta0[0] + R::runif(0.0, 1.0);
meany = meany + yvec[i];
meany2 = meany2 + R_pow(yvec[i], 2.0);
meanxy = meanxy + xvec[i] * yvec[i];
}
meany = meany / (double)n;
meany2 = meany2 / (double)n;
meanxy = meanxy / (double)n;
num = meanxy - meanx * meany;
denom = meanx2 - meanx * meanx;
beta1hat = num / denom;
beta0hat = meany - beta1hat * meanx;
sighat = sqrt((double)n * (meany2 + beta0hat * beta0hat + beta1hat *
beta1hat * meanx2 - 2.0 * beta0hat * meany
- 2.0 * beta1hat * meanxy + 2.0 * beta0hat *
beta1hat * meanx) / (double)(n - 2));
sighatbeta1hat = sighat / sqrt((double)n * denom);
tobs = beta1hat / sighatbeta1hat;
if (fabs(tobs) > thresh) d = d + 1;
}
PutRNGstate();
return Rcpp::wrap((double)d / (double)M[0]);
} // End Cfunc
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel