Each serial number has an associated measurement.
Each measurement is tested to determine if it is less than or equal to 16. This is easy to code using R.
What is less apparent is how to code the serial.test result.
The serial.test result will fail if any one of the measurements associated with that serial number is greater than 16.
I need the serial.test result because I want to create a box plot of the measurements by serial number to help the user see which serial numbers are passing or failing.
library(tidyverse)
# start making example data
set.seed(42)
example_data <- tibble( serial = sample.int(5,size = 15, replace=TRUE),
measurement = sample.int(200,size=15,replace=TRUE) /10) %>% arrange(serial) %>%
mutate(mlte16 = ifelse(measurement > 16 , 'fail','pass'))
#finish example data
#calculate the group outcome
serial.test <- group_by(example_data,
serial) %>% summarise(serial.test=ifelse(max(mlte16=="fail"),
"fail","pass"))
#connect the group outcome back to the original data
example_data2 <- left_join(example_data,
serial.test)