Skip to content

Commit

Permalink
Add volume functions. (#18)
Browse files Browse the repository at this point in the history
* Add volume functions.

* Bump development version number.
MHenderson authored Jun 19, 2024
1 parent b67790b commit 298d4cb
Showing 5 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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"))
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Generated by roxygen2: do not edit by hand

export(n_filled_cells)
export(plot_room_square)
export(volume)
21 changes: 21 additions & 0 deletions R/volume.R
Original file line number Diff line number Diff line change
@@ -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)
}
17 changes: 17 additions & 0 deletions man/n_filled_cells.Rd

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

17 changes: 17 additions & 0 deletions man/volume.Rd

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

0 comments on commit 298d4cb

Please sign in to comment.