Skip to content

Commit

Permalink
Re-type ComputeY as a List.
Browse files Browse the repository at this point in the history
The number of unique elements in different columns in x1 may be
different, which leads to attempting to add vectors of different length
into res. Previously, `push_back` on a DataFrame changed the DataFrame
to a list, which is being addressed in RcppCore/Rcpp#1099. This change,
combined with attempting to add vectors of different lengths, leads to
an error.
  • Loading branch information
waltersom committed Jul 9, 2020
1 parent 788a585 commit 72aa2b1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/testxvalid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ using namespace Rcpp;
//' @param tau2 the residual heterogeneity
//' @keywords internal
// [[Rcpp::export(".ComputeY")]]
DataFrame ComputeY(DataFrame x1, NumericVector y,
List ComputeY(DataFrame x1, NumericVector y,
NumericVector vi, NumericVector tau2) {
int nsplit;
int i;
int j;
DataFrame res;
List res;
for (nsplit = 0; nsplit < x1.ncol(); nsplit++) {
IntegerVector Nodes = x1[nsplit];
IntegerVector uniNodes = Rcpp::sort_unique(Nodes);
IntegerVector uniNodes = Rcpp::sort_unique(Nodes);
NumericVector swyNodes;
for (i = 0; i < uniNodes.length(); i++) {
// compute the weighted sum for each node
Expand All @@ -48,7 +48,6 @@ DataFrame ComputeY(DataFrame x1, NumericVector y,
swyNodes.push_back(sumWY/sumW, to_string(uniNodes[i]));

}

res.push_back(swyNodes);
}

Expand Down

0 comments on commit 72aa2b1

Please sign in to comment.