0
votes

I wrote an R package using RcppArmadillo. In my source file, I had

#include <RcppArmadilloExtensions/sample.h>

in the first line, in order to use the function sample. The package was compiled and checked on my Windows machine, and submitted to CRAN. But it didn't check for the flavors: r-patched-solaris-sparc, r-patched-solaris-x86 with installation errors.

The log file showed

In file included from sim12.cpp:1:0: /home/R/Lib32/RcppArmadillo/include/RcppArmadilloExtensions/sample.h: In function ‘void Rcpp::RcppArmadillo::ProbSampleReplace(arma::uvec&, int, int, arma::vec&)’: /home/R/Lib32/RcppArmadillo/include/RcppArmadilloExtensions/sample.h:149:55: warning: ‘const arma::mtOp arma::sort_index(const arma::Base&, arma::uword) [with T1 = arma::Mat; typename T1::elem_type = double; arma::uword = unsigned int]’ is deprecated [-Wdeprecated-declarations] arma::uvec perm = arma::sort_index(prob, 1); //descending sort of index ^ In file included from /home/R/Lib32/RcppArmadillo/include/armadillo:449:0, from /home/R/Lib32/RcppArmadillo/include/RcppArmadilloForward.h:46, from /home/R/Lib32/RcppArmadillo/include/RcppArmadillo.h:31, from /home/R/Lib32/RcppArmadillo/include/RcppArmadilloExtensions/fixprob.h:25, from /home/R/Lib32/RcppArmadillo/include/RcppArmadilloExtensions/sample.h:30, from sim12.cpp:1: /home/R/Lib32/RcppArmadillo/include/armadillo_bits/fn_sort_index.hpp:37:1: note: declared here sort_index ^

and similar warnings.

To find out how to remedy this, I googled some part of the error messages and found this page (c-style and arma api change compile warning #203):

https://github.com/SMAC-Group/gmwm/issues/203

I believe that the installation error is not due to any particular line in my code following the first line

#include <RcppArmadilloExtensions/sample.h>

but I am not sure how I can resolve this issue. I'd be very grateful for any advice.

1
Very hard / impossible to answer as there is nothing reproducible here and no code to look at. Try this GitHub query for RcppArmadilloExtensions/sample.h to see what other packages are doing. - Dirk Eddelbuettel
This is now taken care of in the master branch. We missed a release by a few days, so the CRAN update will have to wait a few weeks. - Dirk Eddelbuettel
@DirkEddelbuettel Thank you very much for your comments, I'm sorry for not having included any code but I didn't think the issue lied therein and therefore it would not be relevant. - hrcho
That is a bad assumption. Always include a reproducible example. - Dirk Eddelbuettel

1 Answers

1
votes

Well, 'tis always interesting when one of your own GitHub issues comes up on SO...

First, this isn't an error per say, just a warning that it needs to be taken care of soon and it needs to be done upstream.

Basically, the RcppArmadilloExtensions/sample.h API has to be updated because Armadillo's sort( X , sort_direction ) and sort_index( X , sort_direction) functions have moved away from specifying the sort_direction parameter by integer (e.g. 0 = ascend, 1 = descend) in favor of a string interface (e.g. "ascend", "descend").

# Old
arma::sort_index(prob, 1);
# New
arma::sort_index(prob, "descend");

With this being said, I'll make a PR request with the necessary change Dirk will make an issue and then submit a PR that fixes it. Grab the latest development version if you want the most up-to-date test. Likely, this will roll to CRAN in about a month.