You need two colons after Rcpp in the attribute, e.g. Rcpp::export
On Sat, Sep 27, 2014 at 6:30 AM, Kevin Kunzmann <kevinkunzm...@gmx.net> wrote: > Hi, > > I am experiencing a problem with the 'export' attribute. The file > 'cmest.cpp' is compiled all right, but Rcpp misses the function 'cv' both in > RcppExports.cpp as well as RcppExports.R - the compileAttributes() function > ignores the export statement. Other functions are exported correctly form > the same project / source folder! Any Idea? > > Best, > > Kevin > > #include <RcppArmadillo.h> > > // [[Rcpp::depends(RcppArmadillo)]] > > // [[Rcpp:export]] > Rcpp::List cv(arma::mat data, int n) > { > // n must be small enough! > > // find stage one indices > arma::Col<int> inds = arma::Col<int>(data.n_rows); > int nStageOne = 0; > for(int i = 0; i < data.n_rows; i++) > { > inds(nStageOne) = i; > nStageOne += 1; > } > inds.set_size(nStageOne); > > // randomize indices > inds = arma::shuffle(inds); > > // select first n items from each subgroup (marker x treatment) > arma::mat res = arma::zeros<arma::mat>(data.n_rows - 4*n, > data.n_cols); > int nRes = 0; > arma::mat oob = arma::zeros<arma::mat>(n*4, data.n_cols); > arma::Col<int> nCount = arma::zeros<arma::Col<int> >(4); > for(int i = 0; i < nStageOne; i++) > { > if(data(inds(i), 1) == 0 && data(inds(i), 3) == 0 && nCount(0) < n) > { > // 00 > for(int j = 0; j < data.n_cols; j++) > { > oob(sum(nCount), j) = data(inds(i), j); > } > nCount(0) += 1; > continue; > } > if(data(inds(i), 1) == 0 && data(inds(i), 3) == 1 && nCount(1) < n) > { > // 01 > for(int j = 0; j < data.n_cols; j++) > { > oob(sum(nCount), j) = data(inds(i), j); > } > nCount(1) += 1; > continue; > } > if(data(inds(i), 1) == 1 && data(inds(i), 3) == 0 && nCount(2) < n) > { > // 00 > for(int j = 0; j < data.n_cols; j++) > { > oob(sum(nCount), j) = data(inds(i), j); > } > nCount(2) += 1; > continue; > } > if(data(inds(i), 1) == 1 && data(inds(i), 3) == 1 && nCount(3) < n) > { > // 00 > for(int j = 0; j < data.n_cols; j++) > { > oob(sum(nCount), j) = data(inds(i), j); > } > nCount(3) += 1; > continue; > } > // else > for(int j = 0; j < data.n_cols; j++) > { > res(nRes, j) = data(inds(i), j); > } > nRes += 1; > } > return Rcpp::List::create(Rcpp::Named("data") = res, > Rcpp::Named("oob") = oob); > } > _______________________________________________ > Rcpp-devel mailing list > Rcpp-devel@lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel