https://github.com/cran/cutpointr
Tip revision: 030e7096a6bb7c391a35b49ac6eea87ad3b6027a authored by Christian Thiele on 17 September 2019, 20:30:02 UTC
version 1.0.0
version 1.0.0
Tip revision: 030e709
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);
}