Sorry, in the function body, NO 'tab1', use 'x' only: recovery.rate <- function(x) unlist(lapply(split(x, x[,2]), function(x) mean(x[[4]]=="y")))
The error is because 'tab1' existed in the environment and the function would find it. This time, tested after removing 'tab1'. Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/Applying-a-function-tp4229277p4230106.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list 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.