diff --git a/R/simulate.R b/R/simulate.R index cd154a4a..6ff25d88 100644 --- a/R/simulate.R +++ b/R/simulate.R @@ -162,7 +162,10 @@ get_rcrd_values <- function(rname, prov, aggfn, .data, y, censor) { get_record_type(vrcrds, rname), class(y)) # TODO: this is a problem when we have nested_labels - vals <- aggregate_values(y, .data[[uname]], agg_fn) + if(is_null(attr(.data[[uname]], "non-nested"))) + vals <- .data[[uname]] + else vals <- attr(.data[[uname]], "non-nested") + vals <- aggregate_values(y, vals, agg_fn) if(rname %in% names(vrcrds)) { if(is.list(censor) && rname %in% names(censor)) { get_censored_value(vals, vrcrds[[rname]], censor[[rname]])