Skip to content

Commit

Permalink
Fix fmean(c(1L, NA), na.rm = F, g = c(1L, 1L)) issue (#628).
Browse files Browse the repository at this point in the history
  • Loading branch information
SebKrantz committed Sep 7, 2024
1 parent 25b6bdc commit e5d69ae
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/fmean.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ void fmean_int_g_impl(double *restrict pout, const int *restrict px, const int n
R_Free(n);
} else {
--pout;
for(int i = l; i--; ) pout[pg[i]] += px[i]; // Used to stop loop when all groups passed with NA, but probably no speed gain since groups are mostly ordered.
for(int i = l; i--; ) {
pout[pg[i]] += px[i] == NA_INTEGER ? NA_REAL : px[i]; // Used to stop loop when all groups passed with NA, but probably no speed gain since groups are mostly ordered.
}
++pout;
for(int i = ng; i--; ) pout[i] /= pgs[i];
}
Expand Down

0 comments on commit e5d69ae

Please sign in to comment.