First call works; second one does not.
library(randomForest)
data('Boston', package='MASS')
train <- sample(1:nrow(Boston), nrow(Boston) / 2)
randomForest(medv ~ ., data = Boston) |> visreg::visreg('lstat')
randomForest(medv ~ ., data = Boston, subset=train) |> visreg::visreg('lstat')
First call works; second one does not.