Skip to content

Commit

Permalink
A customisable row extension function. (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
MHenderson authored May 29, 2024
1 parent e5e89bf commit 5d6b598
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: keedwell
Title: Latin Squares in R
Version: 0.1.1.9001
Version: 0.1.1.9002
Authors@R:
person("Matthew", "Henderson", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-7949-8208"))
Expand Down
15 changes: 5 additions & 10 deletions R/add-rows.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,22 @@
#'
#' @param R latin rectangle
#' @param rows empty rows to be filled
#' @param strategy row filling strategy
#'
#' @return A latin rectangle with more rows.
#' @return
#' @export
add_rows <- function(R, rows) {
add_rows <- function(R, rows, strategy = next_row_matching) {

# we assume that the dimension equals
# the number of columns
l_order <- length(unique(R$column))

for (i in rows) {

R <- R |>
dplyr::bind_rows(
tibble::tibble(
row = rep(i, l_order),
column = 1:l_order,
symbol = next_row(R, l_order)
)
)
R <- strategy(R, i, l_order)

}

return(R)

}
7 changes: 3 additions & 4 deletions man/add_rows.Rd

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

0 comments on commit 5d6b598

Please sign in to comment.