mfasiolo / mgcViz

An R package for interactive visualization of GAM models
https://mfasiolo.github.io/mgcViz/
76 stars 9 forks source link

Small fix? #68

Closed capezza closed 4 years ago

capezza commented 4 years ago

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, 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)
mfasiolo commented 4 years ago

Good idea, done here c23a317a94f794a754883599a9a3dfbf79a9fc44