Skip to content

Commit

Permalink
update order_trts S3
Browse files Browse the repository at this point in the history
  • Loading branch information
emitanaka committed Nov 11, 2023
1 parent 5d3b413 commit be178de
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export(menu_youden)
export(nested_in)
export(nesting_structure)
export(new_edibble)
export(order_trts)
export(pivot_trts_widelist)
export(pivot_trts_widetable)
export(plot_fct_graph)
Expand Down
6 changes: 4 additions & 2 deletions R/assign.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ assign_trts <- function(.edibble, order = "random", seed = NULL, constrain = nes
},
{
vparents <- prov$fct_id(name = constrain[[unit_nm]])
order_trts(structure(order[igroup], class = order[igroup]), sub_trts_df, sub_units_df, setNames(unit_id, unit_nm), vparents, prov, ...)
order_name <- structure(order[igroup], class = order[igroup])
order_trts(order_name, trts_table = sub_trts_df, units_table = sub_units_df, unit = setNames(unit_id, unit_nm), constrain = vparents, Provenance = prov, ...)
})
permutation[units_df_with_id$..id..[locs]] <- sub_trts_df_with_id[permute, "..id..", drop = TRUE]
}
Expand Down Expand Up @@ -142,7 +143,8 @@ assign_trts <- function(.edibble, order = "random", seed = NULL, constrain = nes
vanc <- prov$fct_id_ancestor(id = unit_id, role = "edbl_unit")
units_df <- tibble::as_tibble(prov$serve_units(id = vanc))
vparents <- prov$fct_id(name = constrain[[unit_nm]])
order_trts(structure(order[igroup], class = order[igroup]), trts_df, units_df, setNames(unit_id, unit_nm), vparents, prov, ...)
order_name <- structure(order[igroup], class = order[igroup])
order_trts(order_name, trts_table = trts_df, units_table = units_df, unit = setNames(unit_id, unit_nm), constrain = vparents, Provenance = prov, ...)
})

}
Expand Down
11 changes: 8 additions & 3 deletions R/permute.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,18 @@ permute_parent_one_alg <- function(vid, udf, ntrts) {
udf[order(udf$.id), ".res", drop = TRUE]
}


#' A custom ordering algorithm
#'
#' @param x A string specifying the class
#' @param ... Other arguments.
#'
#' @export
order_trts <- function(x, ...) {
UseMethod("order_trts")
}

order_trts.default <- function(x, prov, constrain, ...) {
abort(paste("The", order, "`order` is not implemented."))
order_trts.default <- function(x, ...) {
abort(paste("The", cli::col_blue(x), "order is not implemented."))
}

order_trts.dae <- function(x, prov, constrain, trts, ...) {
Expand Down
16 changes: 16 additions & 0 deletions man/order_trts.Rd

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

0 comments on commit be178de

Please sign in to comment.