// [[Rcpp::export]] double obsHet(CharacterMatrix in_mat) { //CharacterVector new_mat = in_mat(_,1) ; int n = in_mat.nrow() ; double total = 0 ; double ns = 0 ; for(int i = 0; i < n; i++){ CharacterVector tst = in_mat(i,_) ; LogicalVector id = is_na(tst) ; if(tst[0] != tst[1]){ total += 1 ; } if(!id[0]) { ns += 1 ; } } return total/ns ; }
// [[Rcpp::export]] LogicalVector sequenceChecker_cpp(CharacterMatrix x){ int nc = x.ncol() ; CharacterVector ns(x.nrow()); CharacterVector Ns(x.nrow()); std::fill(ns.begin(), ns.end(), "n"); std::fill(Ns.begin(), Ns.end(), "N"); LogicalVector out(nc); for(int i=0; i < nc; i++){ out[i] = is_false(any(x(_,i) == Ns)) && is_false(any(x(_,i) == ns)) && unique(x(_,i)).size() != 1; } return out; }