https://github.com/cran/cutpointr
Tip revision: 2a9508b29dfa63182cfa56e60908d36e099266fd authored by Christian Thiele on 29 June 2021, 05:30:02 UTC
version 1.1.1
version 1.1.1
Tip revision: 2a9508b
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);
}