Revision d461e559d4a76b7fcbd728470ca12cce56d3ffab authored by Christian Thiele on 19 June 2020, 11:00:06 UTC, committed by cran-robot on 19 June 2020, 11:00:06 UTC
1 parent bbfd829
Raw File
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