'using exact_extract from exactextractr in R

I am trying to run the example code from the exactextractr package in R

library(raster)
library(sf)
library(exactextractr)


    brazil <- st_as_sf(getData('GADM', country='BRA', level=2))
    
    
    prec <- getData('worldclim', var='prec', res=10)
    
    brazil$mean_dec_prec <- exact_extract(prec[[12]], brazil, 'mean')
    
    
    brazil <- cbind(brazil, exact_extract(prec, brazil, c('min', 'max')))

When I get to the third line I keep getting the following error

    in CPP_stats(x, weights, wkb, default_value, default_weight, coverage_area,  : 
  Cannot convert object to a function: [type=NULL; target=CLOSXP, SPECIALSXP, or BUILTINSXP].

I've searched around but I can't find anyone else having this error, I've had other people run the code, we are using the same package versions and it works fine for them.

Does anyone have any ideas on the problem or how to fix it?

Thanks, Dave

rsf


Solution 1:[1]

It seems this was a package version issue, resolved by updating.

I was able to reproduce the bug with version 0.5.2, but it worked fine with version 0.7.2

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Matifou