diff --git a/DESCRIPTION b/DESCRIPTION index b7a1ea6..433d8e2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: keedwell Title: Latin Squares in R -Version: 0.1.1.9002 +Version: 0.1.1.9003 Authors@R: person("Matthew", "Henderson", , "matthew.james.henderson@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7949-8208")) diff --git a/NAMESPACE b/NAMESPACE index 9f5d919..1acb1ee 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,3 +2,4 @@ export(add_cols) export(add_rows) +export(first_row_natural) diff --git a/R/add-rows.R b/R/add-rows.R index cbb53d2..ea01385 100644 --- a/R/add-rows.R +++ b/R/add-rows.R @@ -13,7 +13,7 @@ #' @param rows empty rows to be filled #' @param strategy row filling strategy #' -#' @return +#' @return A latin rectangle #' @export add_rows <- function(R, rows, strategy = next_row_matching) { diff --git a/R/first-row.R b/R/first-row.R new file mode 100644 index 0000000..52e403d --- /dev/null +++ b/R/first-row.R @@ -0,0 +1,10 @@ +#' First row in in natural order +#' +#' @param n Number of columns +#' +#' @return A 1 x n latin rectangle with first row 1,...,n +#' @export +first_row_natural <- function(n) { + tidyr::expand_grid(row = 1:1, column = 1:n) |> + dplyr::mutate(symbol = 1:n) +} \ No newline at end of file diff --git a/man/add_rows.Rd b/man/add_rows.Rd index 6df4b35..0b994e8 100644 --- a/man/add_rows.Rd +++ b/man/add_rows.Rd @@ -13,6 +13,9 @@ add_rows(R, rows, strategy = next_row_matching) \item{strategy}{row filling strategy} } +\value{ +A latin rectangle +} \description{ Input is a latin rectangle as a data frame with variables for row, column and symbol. Output is diff --git a/man/first_row_natural.Rd b/man/first_row_natural.Rd new file mode 100644 index 0000000..e01f5da --- /dev/null +++ b/man/first_row_natural.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/first-row.R +\name{first_row_natural} +\alias{first_row_natural} +\title{First row in in natural order} +\usage{ +first_row_natural(n) +} +\arguments{ +\item{n}{Number of columns} +} +\value{ +A 1 x n latin rectangle with first row 1,...,n +} +\description{ +First row in in natural order +}