https://github.com/cran/cutpointr
Tip revision: bbfd8290a255cf1d55a1eed28f5501736e754842 authored by Christian Thiele on 14 April 2020, 07:50:10 UTC
version 1.0.2
version 1.0.2
Tip revision: bbfd829
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);
}