Error when using a RasterBrick to running vifstep() from usdm in R

153 Views Asked by At

I'm trying to use a RasterBrick to run the vifstep function from usdm in R and I'm getting the following error:

Error in model.frame.default(formula = .dd[, i] ~ ., data = .dd[-i], drop.unused.levels = TRUE) : 'data' must be a data.frame, environment, or list

class(pred.mask)
[1] "RasterBrick"
attr(,"package")
[1] "raster"

vif.step <- usdm::vifstep(pred.mask,
                          th = 5,
                          method = "pearson")

I was expecting that it would work since the function's help defines that the data can be "a raster object (RasterStack or RasterBrick or SpatRaster), or as a matrix, or as a data.frame."

1

There are 1 best solutions below

2
Oliver_C On

Update: I reached out to the package developer who advised I use a SpatRaster rather than a RasterStack so I converted using the terra::rast function and it worked thereafter...