https://github.com/cran/cutpointr
Tip revision: 94a7e298b1a50d93e8a9ccb813a070f7b30f3da1 authored by Christian Thiele on 21 March 2018, 08:27:24 UTC
version 0.7.2
version 0.7.2
Tip revision: 94a7e29
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);
}