ying
ying

Reputation: 31

Error on Rcpp::depends when using sourceCpp and RcppArmadillo

The code can run through on my desktop. I tried to run it on a server and got error Error: Package 'RcppArmadillo' referenced from Rcpp::depends in source file is not available. I wonder if something wrong when I installed the packages but I have no idea how to fix it.

The R script is like this

> library(Rcpp,lib="~/R_libs")
> library(RcppArmadillo,lib="~/R_libs")
> library(gtools,lib="~/R_libs")
> Rcpp::sourceCpp('~/Test/probit2.cpp')
Error: Package 'RcppArmadillo' referenced from Rcpp::depends in source 
file probit2.cpp is not available.`

And the cpp file begins with this

#include "RcppArmadillo.h"
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;

Thanks in advance!

Upvotes: 2

Views: 1470

Answers (1)

ying
ying

Reputation: 31

Thanks for all the comments above, I solved this by setting this from the terminal:

export R_LIBS="~/myRlib"
Rscript myscript.r

I could also set .libPaths("~/myRlib") in the R script.

Upvotes: 1

Related Questions