-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#' Comparing dish washing detergents | ||
#' | ||
#' An experiment was carried out to compare dish washing detergents. Standard | ||
#' plates were soiled with standard dirt, and an operator then washed the plates | ||
#' in a detergent solution one at a time. The response variable was the number | ||
#' of plates washed before the foam disappeared. Three basins were set up, with | ||
#' an operator for each, and the three Operators took care to wash at the same | ||
#' rate. A different detergent was used in each basin. Thus the experimental | ||
#' unit was a single washing-up session in one basin, and the units were grouped | ||
#' in blocks of three (being the washing-up sessions carried out | ||
#' simultaneously). Since there were nine detergents to compare in blocks of | ||
#' size three, a balanced incomplete block design was used. | ||
#' | ||
#' @format A data frame with 36 rows and 3 columns: | ||
#' \describe{ | ||
#' \item{block}{Washing up session. Factor with levels '1' to '12'} | ||
#' \item{detergent}{Detergent brand. Factor with levels '1' to '9'} | ||
#' \item{plates}{Number of plates washed until the foam disappeared} | ||
#' } | ||
#' | ||
#' @example inst/examples/dishwash.R | ||
#' | ||
#' @source {John, P.W.M. (1961) \emph{An application of a balanced incomplete | ||
#' block design}, Technometrics, 3, 51-54.} | ||
"dishwash" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# DISHWASH - data raw | ||
library(tidyverse) | ||
|
||
dishwash <- readr::read_delim( | ||
file = here::here("data-raw", "data-files", "dishwash.dat"), | ||
col_types = c("i", rep("c", 9)), | ||
col_names = c("block", paste0("detergent_", 1:9)), | ||
delim = "\t" | ||
) %>% | ||
pivot_longer( | ||
cols = starts_with("detergent"), | ||
names_to = "detergent", | ||
names_prefix = "detergent_", | ||
values_to = "plates" | ||
) %>% | ||
mutate( | ||
plates = str_remove_all(plates, "�") %>% as.numeric(), | ||
block = as_factor(block), | ||
detergent = as_factor(detergent), | ||
) %>% | ||
filter(!is.na(plates)) %>% | ||
labelled::set_variable_labels( | ||
block = "Washing session", | ||
detergent = "Detergent brand", | ||
plates = "Number of plates washed" | ||
) | ||
|
||
usethis::use_data(dishwash, overwrite = TRUE) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
library(dplyr) | ||
library(tidyr) | ||
library(gt) | ||
library(hsds) | ||
|
||
# Generate all possible cases of detergent and block, then add the recorded | ||
# values from the experiment | ||
all_cases <- dishwash %>% | ||
expand(block, detergent) %>% | ||
left_join(dishwash, by = join_by(block, detergent)) | ||
|
||
# Display as a visually appealling table, showing the incomplete blocked design | ||
# structure | ||
all_cases %>% | ||
labelled::set_variable_labels(plates = NULL) %>% | ||
pivot_wider( | ||
names_from = "detergent", | ||
values_from = "plates" | ||
) %>% | ||
gt() %>% | ||
sub_missing() %>% | ||
cols_label(block ~ "Block") %>% | ||
tab_spanner("Detergent", columns = -block) %>% | ||
cols_width(everything() ~ px(40)) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.