0

When using the function by, at times I will have a data subset (as determined by the INDICES argument) that 'breaks' by (technically it breaks FUN which in turn breaks by).

Is there a way to identify the 'bad' value of the list passed to INDICES? (without writing an explicit loop over the list)

Jubbles
  • 4,450
  • 8
  • 35
  • 47

1 Answers1

0

Can you make a reproducible example?

You can try something like,

customfun <- function(x)try(somefun(x))
byresult <- by(mydata, mydata$group, FUN=customfun)
whichbad <- sapply(byresult, function(x)which(inherits(x, "try-error")))
Remko Duursma
  • 2,741
  • 17
  • 24