Skip to content

Commit 6801f8d

Browse files
committed
corrected LGLSXP case (with a thanking no to Kevin...)
1 parent f257155 commit 6801f8d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

ChangeLog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
2015-01-01 Dirk Eddelbuettel <[email protected]>
22

33
* inst/include/Rcpp/sugar/functions/mean.h: Return type is double, not
4-
storage type; also added logical vector case [in progress]
4+
storage type; also added logical vector case
55

66
2014-12-31 Dirk Eddelbuettel <[email protected]>
77

inst/include/Rcpp/sugar/functions/mean.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ class Mean<LGLSXP,NA,T> : public Lazy<double, Mean<LGLSXP,NA,T> > {
9797

9898
double get() const {
9999
LogicalVector input = object;
100-
int n = input.size(); // double pass (as in summary.c)
100+
int n = input.size();
101101
long double s = 0.0;
102102
for (int i=0; i<n; i++) {
103-
if (input[i] == NA) return NA;
104-
s += (input[i] == TRUE);
103+
if (input[i] == NA_INTEGER) return NA_REAL;
104+
s += input[i];
105105
}
106106
s /= n; // no overflow correction needed for logical vectors
107107
return (double)s;

0 commit comments

Comments
 (0)