Error FUN(X[[i]], ...)

This is probably all that is needed to troubleshoot, minus the geom_jitter, but it is simply too much trouble to reverse engineer in the absence of m1. With a reprex you may attract some answers.

See the FAQ: How to do a minimal reproducible example reprex for beginners.