Error in FUN(X[[i]], ...) : object 'variable' not found

The error message suggests there is no column called variable in your PM_max2 data frame, double-check on that and have in mind that R is case sensitive.

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.