I have the following dataframe called data:
I am trying to create a function which determines out of specification values of "Assayperc" as follows:
is_oos <- function(x){
return(x < (data$Assayperc < 0.90 && data$Assayperc > 1.10))
}
In other words out of specifiation are Assayperc values less than 90% or greater than 110%.
I then want to use the "is_oos" function to add a out of specificatio column to the data frame as follows:
data <- data %>%
group_by(Manufacturer) %>%
mutate(OutOfSpec = ifelse(is_oos(Assayperc), BatchNumber, ""))
The output is as follows which is not as expected as all values are being labelled as out of specification:
Kindly assist with the function.
Regards Chris