From 7994ed1a44389c7a08ffb571747945be93bd6e61 Mon Sep 17 00:00:00 2001 From: Matthew Henderson Date: Mon, 22 Apr 2024 08:59:18 +0100 Subject: [PATCH] Prepare first release (#7) * Add documentation. * Prepare for release. --- DESCRIPTION | 4 ++-- NAMESPACE | 5 +++++ NEWS.md | 5 +++++ R/add-rows.R | 4 +--- R/create-latin-square.R | 6 ++---- R/edge-tbl.R | 4 +--- R/next-row.R | 8 +++----- R/to-tidygraph.R | 7 +++---- keedwell.Rproj | 1 + man/add_rows.Rd | 27 +++++++++++++++++++++++++++ man/create_latin_square.Rd | 19 +++++++++++++++++++ man/edge_tbl.Rd | 27 +++++++++++++++++++++++++++ man/next_row.Rd | 27 +++++++++++++++++++++++++++ man/to_tidygraph.Rd | 23 +++++++++++++++++++++++ 14 files changed, 146 insertions(+), 21 deletions(-) create mode 100644 NEWS.md create mode 100644 man/add_rows.Rd create mode 100644 man/create_latin_square.Rd create mode 100644 man/edge_tbl.Rd create mode 100644 man/next_row.Rd create mode 100644 man/to_tidygraph.Rd diff --git a/DESCRIPTION b/DESCRIPTION index a20cb60..e802eaa 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: keedwell Title: Latin Squares in R -Version: 0.0.0.9000 +Version: 0.1.0 Authors@R: person("Matthew", "Henderson", , "matthew.james.henderson@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7949-8208")) @@ -14,4 +14,4 @@ Imports: purrr, tibble, tidygraph, - tidyr \ No newline at end of file + tidyr diff --git a/NAMESPACE b/NAMESPACE index 6ae9268..2ed5ff9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,2 +1,7 @@ # Generated by roxygen2: do not edit by hand +export(add_rows) +export(create_latin_square) +export(edge_tbl) +export(next_row) +export(to_tidygraph) diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..0bbbe07 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,5 @@ +# keedwell (development version) + +# keedwell (v0.1.0) + +* Imported functions from mhall-in-r. diff --git a/R/add-rows.R b/R/add-rows.R index 45c467f..c9da077 100644 --- a/R/add-rows.R +++ b/R/add-rows.R @@ -12,10 +12,8 @@ #' @param R latin rectangle #' @param rows empty rows to be filled #' -#' @return +#' @return A latin rectangle with more rows. #' @export -#' -#' @examples add_rows <- function(R, rows) { # we assume that the dimension equals diff --git a/R/create-latin-square.R b/R/create-latin-square.R index 583239f..bcba7df 100644 --- a/R/create-latin-square.R +++ b/R/create-latin-square.R @@ -4,12 +4,10 @@ #' 1 x l_order latin rectangle and then embedding #' it in a latin square. #' -#' @param l_order +#' @param l_order Latin square order. #' -#' @return +#' @return A latin square. #' @export -#' -#' @examples create_latin_square <- function(l_order) { tidyr::expand_grid(row = 1:1, column = 1:l_order) |> dplyr::mutate(symbol = 1:l_order) |> diff --git a/R/edge-tbl.R b/R/edge-tbl.R index ae392c2..6e76887 100644 --- a/R/edge-tbl.R +++ b/R/edge-tbl.R @@ -11,10 +11,8 @@ #' @param i column #' @param l_order size of latin square R is going to be embedded into #' -#' @return +#' @return The edge data frame. #' @export -#' -#' @examples edge_tbl <- function(R, i, l_order = 3) { all_symbols <- 1:l_order diff --git a/R/next-row.R b/R/next-row.R index b4ec9b2..afd2e5c 100644 --- a/R/next-row.R +++ b/R/next-row.R @@ -9,13 +9,11 @@ #' missing from columns and then find a maximum #' matching in that bipartite graph. #' -#' @param R -#' @param l_order +#' @param R A latin square +#' @param l_order The order of the input latin square #' -#' @return +#' @return A bipartite graph. #' @export -#' -#' @examples next_row <- function(R, l_order) { bg <- to_tidygraph(R, l_order) diff --git a/R/to-tidygraph.R b/R/to-tidygraph.R index d415a92..62bfbc3 100644 --- a/R/to-tidygraph.R +++ b/R/to-tidygraph.R @@ -6,12 +6,11 @@ #' vertices for columns and symbols and edges representing #' symbols missing from columns. #' -#' @param R +#' @param R A latin rectangle. +#' @param l_order Order of R. #' -#' @return +#' @return A bipartite graph. #' @export -#' -#' @examples to_tidygraph <- function(R, l_order = 3) { ## VERTEX DATA FRAME diff --git a/keedwell.Rproj b/keedwell.Rproj index 008497b..b363f18 100644 --- a/keedwell.Rproj +++ b/keedwell.Rproj @@ -15,5 +15,6 @@ LaTeX: pdfLaTeX BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace UseNativePipeOperator: Yes diff --git a/man/add_rows.Rd b/man/add_rows.Rd new file mode 100644 index 0000000..36c0675 --- /dev/null +++ b/man/add_rows.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/add-rows.R +\name{add_rows} +\alias{add_rows} +\title{Embed latin rectangle in a latin square} +\usage{ +add_rows(R, rows) +} +\arguments{ +\item{R}{latin rectangle} + +\item{rows}{empty rows to be filled} +} +\value{ +A latin rectangle with more rows. +} +\description{ +Input is a latin rectangle as a data frame with +variables for row, column and symbol. Output is +a latin square in the same format which contains +the given latin rectangle in the first rows. +} +\details{ +Use can optionally provide a vector of row indices. +Only those rows will be filled if that optional +vector is provided. +} diff --git a/man/create_latin_square.Rd b/man/create_latin_square.Rd new file mode 100644 index 0000000..0eb16d0 --- /dev/null +++ b/man/create_latin_square.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/create-latin-square.R +\name{create_latin_square} +\alias{create_latin_square} +\title{Generate latin squares} +\usage{ +create_latin_square(l_order) +} +\arguments{ +\item{l_order}{Latin square order.} +} +\value{ +A latin square. +} +\description{ +Create a latin square by first generating a +1 x l_order latin rectangle and then embedding +it in a latin square. +} diff --git a/man/edge_tbl.Rd b/man/edge_tbl.Rd new file mode 100644 index 0000000..31f69e8 --- /dev/null +++ b/man/edge_tbl.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/edge-tbl.R +\name{edge_tbl} +\alias{edge_tbl} +\title{Symbols missing from columns edge data frame} +\usage{ +edge_tbl(R, i, l_order = 3) +} +\arguments{ +\item{R}{latin rectangle} + +\item{i}{column} + +\item{l_order}{size of latin square R is going to be embedded into} +} +\value{ +The edge data frame. +} +\description{ +Constructs a data frame representing the edges +of a bipartite graph based on a latin rectangle +where the graph has an edge for every symbol not +already used in a column. +} +\details{ +Acutally, this is just for one column. +} diff --git a/man/next_row.Rd b/man/next_row.Rd new file mode 100644 index 0000000..52e896f --- /dev/null +++ b/man/next_row.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/next-row.R +\name{next_row} +\alias{next_row} +\title{Find a compatible row for extending a latin rectangle} +\usage{ +next_row(R, l_order) +} +\arguments{ +\item{R}{A latin square} + +\item{l_order}{The order of the input latin square} +} +\value{ +A bipartite graph. +} +\description{ +Given an input latin rectangle this function will +generate a new row that can be added to the latin +rectangle. +} +\details{ +The method used is to create a bipartite graph +with vertex partitions for columns and symbols +missing from columns and then find a maximum +matching in that bipartite graph. +} diff --git a/man/to_tidygraph.Rd b/man/to_tidygraph.Rd new file mode 100644 index 0000000..db0b95f --- /dev/null +++ b/man/to_tidygraph.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/to-tidygraph.R +\name{to_tidygraph} +\alias{to_tidygraph} +\title{Symbols missing from columns bipartite graph} +\usage{ +to_tidygraph(R, l_order = 3) +} +\arguments{ +\item{R}{A latin rectangle.} + +\item{l_order}{Order of R.} +} +\value{ +A bipartite graph. +} +\description{ +Input is a latin rectangle as a data frame with +variables for row, column and symbol. Output is +a tidygraph representing the bipartite graph with +vertices for columns and symbols and edges representing +symbols missing from columns. +}