Skip to content

Commit

Permalink
fix for rbind
Browse files Browse the repository at this point in the history
  • Loading branch information
emitanaka committed Nov 26, 2023
1 parent 4149bc0 commit 790f593
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ S3method(print,recipe_design)
S3method(print,sim_process)
S3method(print,split_by)
S3method(print,takeout)
S3method(rbind,edbl_table)
S3method(tbl_sum,edbl_table)
S3method(tbl_sum,trck_table)
S3method(type_sum,edbl_fct)
Expand Down
10 changes: 6 additions & 4 deletions R/simulate.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ with_params <- function(..., .censor = NA, .aggregate = NULL) {
#' simulate_process(y = function() {
#' res <- rnorm(n())
#' res
#'. }) %>%
#' }) %>%
#' simulate_rcrds(y = with_params(), .nsim = 3)
#'
#'
Expand Down Expand Up @@ -238,7 +238,7 @@ get_censored_value <- function(y, valid, censor) {
} else if(type=="integer") {
valid$record <- "numeric"
res <- get_censored_value(y, valid, censor)
round(res)
as.integer(round(res))
} else {
y
}
Expand Down Expand Up @@ -344,8 +344,9 @@ with_variables <- function(...,
#' @param ... If supplied, it is a name-value pair where the name should
#' correspond to the record factor name and value is the f
#' @param .seed The seed number.
#' @param .nsim The number of simulations to run.
#' @export
autofill_rcrds <- function(.data, ..., .seed = NULL) {
autofill_rcrds <- function(.data, ..., .seed = NULL, .nsim = 1L) {
prov <- activate_provenance(.data)
prov$save_seed(.seed, type = "autofill_rcrds")
dots <- list2(...)
Expand Down Expand Up @@ -456,7 +457,8 @@ autofill_rcrds <- function(.data, ..., .seed = NULL) {


simulate_processes <- sprintf("simulate_process(%s)", paste(process_functions, collapse = ",\n"))
simulate_rcrds <- paste0('simulate_rcrds(', paste0(processes, collapse = ',\n '), ')')
simulate_rcrds <- paste0('simulate_rcrds(', paste0(processes, collapse = ',\n '),
', .nsim = ', .nsim, ')')
final_code <- parse(text = paste(".data %>%\n ", simulate_processes, "%>%\n ", simulate_rcrds))
eval(final_code)
}
Expand Down
5 changes: 4 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -473,4 +473,7 @@ print.edbl_fct <- function(x, ...) {
}
}


#' @export
rbind.edbl_table <- function(...) {
dplyr::bind_rows(...)
}
4 changes: 3 additions & 1 deletion man/autofill_rcrds.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/simulate_rcrds.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 790f593

Please sign in to comment.