Skip to content

Commit

Permalink
update simulate for integer
Browse files Browse the repository at this point in the history
  • Loading branch information
emitanaka committed Sep 27, 2023
1 parent 71e6a2e commit 7fec1c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions R/design.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ design <- function(title = NULL, name = "edibble", .record = TRUE, seed = NULL,
provenance$set_name(name)
provenance$save_seed(seed, type = "design")
structure(list(graph = provenance$get_graph(),
validation = list(rcrds = NULL),
provenance = provenance,
anatomy = NULL,
recipe = NULL,
Expand Down
9 changes: 7 additions & 2 deletions R/simulate.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ get_rcrd_values <- function(rname, prov, aggfn, .data, y, censor) {
get_censored_value <- function(y, valid, censor) {
if(is_null(valid)) return(y)
type <- valid$record
# add type == "whole" for integer.
if(type=="numeric") {
value <- valid$value
valid_env <- rlang::current_env()
Expand Down Expand Up @@ -213,6 +212,12 @@ get_censored_value <- function(y, valid, censor) {
y[!ind] <- censor
}
y
} else if(type=="integer") {
valid$record <- "numeric"
res <- get_censored_value(y, valid, censor)
round(res)
} else {
y
}
}

Expand Down Expand Up @@ -372,7 +377,7 @@ autofill_rcrds <- function(.data, ..., .seed = NULL) {
if(is.na(deps[[rname]]$type)) {
code_list <- effects_code(dep_fcts, .data, code_list)
code_adjust_y <- ""
} else if(deps[[rname]]$type=="numeric") {
} else if(deps[[rname]]$type %in% c("numeric", "integer")) {
if(vrcrds[[rname]]$operator == "equal" | (vrcrds[[rname]]$operator == "between" && vrcrds[[rname]]$value[1] == vrcrds[[rname]]$value[2])) {
code_list <- list(process_code = "",
model_code = "")
Expand Down

0 comments on commit 7fec1c3

Please sign in to comment.