Suppose you have few data to use for the ALEplot, in such case it can happen that in a bin only one observation is available, then in this function alpha has only one row, and using sapply returns a numeric instead of a matrix, then DaDe[, ii] returns an error some lines below.
I would suggest to add this line after the sapply:
if (nrow(alpha) == 1) DaDe <- matrix(DaDe, nrow = 1)
https://github.com/mfasiolo/mgcViz/blob/179c77cf0e6cd85b9711e7103328085ebc2e5da9/R/I_multinomJacobian.R#L14-L16
Suppose you have few data to use for the ALEplot, in such case it can happen that in a bin only one observation is available, then in this function
alpha
has only one row, and using sapply returns a numeric instead of a matrix, thenDaDe[, ii]
returns an error some lines below.I would suggest to add this line after the sapply: