From 94dd0a65ecb289cc09613d2606ebc6033aaa3134 Mon Sep 17 00:00:00 2001 From: Matthew Henderson Date: Wed, 19 Jun 2024 06:58:20 +0000 Subject: [PATCH 1/2] Add volume functions. --- NAMESPACE | 2 ++ R/volume.R | 21 +++++++++++++++++++++ man/n_filled_cells.Rd | 17 +++++++++++++++++ man/volume.Rd | 17 +++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 R/volume.R create mode 100644 man/n_filled_cells.Rd create mode 100644 man/volume.Rd diff --git a/NAMESPACE b/NAMESPACE index a3e4840..f691bd2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,3 +1,5 @@ # Generated by roxygen2: do not edit by hand +export(n_filled_cells) export(plot_room_square) +export(volume) diff --git a/R/volume.R b/R/volume.R new file mode 100644 index 0000000..aa36336 --- /dev/null +++ b/R/volume.R @@ -0,0 +1,21 @@ +#' Number of filled cells in a partial Room square +#' +#' @param R A partial Room square +#' +#' @return The number of filled cells in R. +#' @export +n_filled_cells <- function(R) { + R |> + dplyr::filter(!is.na(first)) |> + nrow() +} + +#' Volume of a partial Room square +#' +#' @param R A partial Room square. +#' +#' @return The volume of R. +#' @export +volume <- function(R) { + round(n_filled_cells(R)/choose(max(R$col) + 1, 2), 6) +} \ No newline at end of file diff --git a/man/n_filled_cells.Rd b/man/n_filled_cells.Rd new file mode 100644 index 0000000..5d6f110 --- /dev/null +++ b/man/n_filled_cells.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/volume.R +\name{n_filled_cells} +\alias{n_filled_cells} +\title{Number of filled cells in a partial Room square} +\usage{ +n_filled_cells(R) +} +\arguments{ +\item{R}{A partial Room square} +} +\value{ +The number of filled cells in R. +} +\description{ +Number of filled cells in a partial Room square +} diff --git a/man/volume.Rd b/man/volume.Rd new file mode 100644 index 0000000..8dc6d72 --- /dev/null +++ b/man/volume.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/volume.R +\name{volume} +\alias{volume} +\title{Volume of a partial Room square} +\usage{ +volume(R) +} +\arguments{ +\item{R}{A partial Room square.} +} +\value{ +The volume of R. +} +\description{ +Volume of a partial Room square +} From 85c0255438d9c9d03bbb7f556dbd70fef5c41bde Mon Sep 17 00:00:00 2001 From: Matthew Henderson Date: Wed, 19 Jun 2024 07:03:41 +0000 Subject: [PATCH 2/2] Bump development version number. --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8c868cf..0eb86d6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: wallis Title: Room squares in R -Version: 0.0.0.9001 +Version: 0.0.0.9002 Authors@R: person("Matthew", "Henderson", , "matthew.james.henderson@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7949-8208"))