I want to group the dataset by name and if the same name includes at least one 0 in the response column, I want to assign it as 0 else 1. Please see the data and output.
data = data.frame(stringsAsFactors = FALSE,
name = c("Mary", "Frank", "Tom", "Frank", "Mary"),
response = c(1, 0, 1, 0, 0))
For instance, Mary's response values are 0 and 1, so I will assign it as 0. See the output below.
Output = data.frame(stringsAsFactors = FALSE,
name = c("Mary", "Frank", "Tom"),
response = c(0, 0, 1))