On 22/03/20 8:44 pm, Deepayan Sarkar wrote:

Another possible approach is to use split -> lapply -> rbind, which I
often find to be conceptually simpler:

d <- data.frame(Serial = c(1, 1, 2, 2, 2, 3, 3),
                 Measurement = c(17, 16, 12, 8, 10, 19, 13))

dlist <- split(d, d$Serial)
dlist <- lapply(dlist, within,
{
     Serial_test <- if (all(Measurement <= 16)) "pass" else "fail"
     Meas_test <- ifelse(Measurement <= 16, "pass", "fail")
})
do.call(rbind, dlist)

Yes!!! Much sexier than my clumsy hack-and-grind approach!

cheers,

Rolf

--
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to