Skip to content

Commit

Permalink
Merge pull request #715 from SebKrantz/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
SebKrantz authored Jan 9, 2025
2 parents b567e57 + 8916081 commit ee6f69f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ SEXP match_single(SEXP x, SEXP table, SEXP nomatch) {
if(tx == INTSXP-1) { // For factors there is a shorthand: just match the levels against table...
SEXP nmvint = PROTECT(ScalarInteger(nmv)); ++nprotect;
SEXP tab = PROTECT(match_single(getAttrib(x, R_LevelsSymbol), table, nmvint)); ++nprotect;
int *pans = INTEGER(ans), *pt = INTEGER(tab)-1, *px = INTEGER(x);
int *pans = INTEGER(ans), *pt = INTEGER(tab), *px = INTEGER(x);
if(inherits(x, "na.included")) {
#pragma omp simd
for(int i = 0; i < n; ++i) pans[i] = pt[px[i]];
for(int i = 0; i < n; ++i) pans[i] = pt[px[i]-1];
} else {
int na_ind = 0;
// Need to take care of possible NA matches in table..
Expand Down Expand Up @@ -87,7 +87,7 @@ SEXP match_single(SEXP x, SEXP table, SEXP nomatch) {
}
if(na_ind == 0) na_ind = nmv;
#pragma omp simd
for(int i = 0; i < n; ++i) pans[i] = px[i] == NA_INTEGER ? na_ind : pt[px[i]];
for(int i = 0; i < n; ++i) pans[i] = px[i] == NA_INTEGER ? na_ind : pt[px[i]-1];
}
UNPROTECT(nprotect);
return ans;
Expand Down

0 comments on commit ee6f69f

Please sign in to comment.