Skip to content

Commit 9256ad7

Browse files
committed
comments only
1 parent b0e6ba1 commit 9256ad7

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

R/last.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ last = function(x, n=1L, na.rm=FALSE, ...) {
7676
# and/or pad= could be added to [.data.table to allow padding all results
7777
# Since gforce_dynamic optimizes head/tail it knows to pad and that's optimized. However, default last(x) and first(x) (i.e. n=1 na.rm=FALSE) are
7878
# single-valued like mean,median etc and are recycled in the same way. This is consistent with n=1 na.rm=FALSE already not being treated as
79-
# gforce_dynamic in gsumm.c either.
80-
# ***** TODO *****: n=1 na.rm=TRUE is not vector result and should be recycled to be consistent with n=1 na.rm=FALSE. It's just n>1 that is true vector then.
79+
# gforce_dynamic in gsumm.c either. n=1 na.rm=TRUE returns empty when all-NA so is still a vector result not recycled when length-1.
8180
ans
8281
}
8382

src/gsumm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ static SEXP gfirstlast(const SEXP x, const bool first, const SEXP nArg, const bo
11351135
SEXP att, v;
11361136
setAttrib(ans, sym_gforce_dynamic, att=allocVector(VECSXP, 3));
11371137
SET_VECTOR_ELT(att, 0, v = narm ? allocVector(INTSXP, ngrp) : R_NilValue);
1138-
SET_VECTOR_ELT(att, 1, ScalarLogical(first)); // so gforce knows which end to pad if necessary
1138+
SET_VECTOR_ELT(att, 1, ScalarLogical(first)); // so gforce knows which end the data is (last writes from the end of the alloc)
11391139
SET_VECTOR_ELT(att, 2, ScalarInteger(w)); // to know how many were allocated for each group; i.e. MIN(w,grpsize[i])
11401140
if (narm) anslens = INTEGER(v);
11411141
}

0 commit comments

Comments
 (0)