https://github.com/cran/cutpointr
Raw File
Tip revision: 7e56c827a694247d212e9a0167a119f917e1f31b authored by Christian Thiele on 31 August 2018, 15:50:10 UTC
version 0.7.4
Tip revision: 7e56c82
which.cpp
#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
IntegerVector which_are_num(NumericVector x, double a) {
    int nx = x.size();
    std::vector<int> y;
    y.reserve(nx);

    for(int i = 0; i < nx; i++) {
        if (x[i] == a) y.push_back(i+1);
    }

    return wrap(y);
}

// [[Rcpp::export]]
IntegerVector which_are_char(CharacterVector x, String a) {
    int nx = x.size();
    std::vector<int> y;
    y.reserve(nx);

    for(int i = 0; i < nx; i++) {
        if (x[i] == a) y.push_back(i+1);
    }

    return wrap(y);
}
back to top