1
#include <Rcpp.h>
2
using namespace Rcpp;
3

4

5
// [[Rcpp::export]]
6 1
IntegerMatrix rankings(std::vector<std::vector<int> > paths,
7
                       std::vector<std::vector<int> > ideals,
8
                       int nRank,
9
                       int nElem) {
10
  
11 1
  IntegerMatrix rks(nElem,nRank);
12 1
  for(int i=0; i<nRank; ++i){
13 1
    std::vector<int> pths=paths[i];
14 1
    for(int j=0;j<nElem; ++j){
15 1
      int t=pths[j+1];
16 1
      int s=pths[j];
17
      int x;
18 1
      std::set_difference(ideals[t].begin(), ideals[t].end(),
19 1
                          ideals[s].begin(), ideals[s].end(), &x);
20 1
      rks(x,i)=j;
21
    }
22
  }
23
  
24
  
25 1
  return rks;
26
}
27

Read our documentation on viewing source code .

Loading