isciences / exactextractr

R package for fast and accurate raster zonal statistics
https://isciences.gitlab.io/exactextractr/
274 stars 26 forks source link

Summarizing categorical data #50

Closed RS-eco closed 3 years ago

RS-eco commented 3 years ago

Hello,

I tried to use the summarize_df=T feature in the exact_extract() function, but using your own examples from within the package vignettes:

landcov_fracs <- exact_extract(clc, concelhos, function(df) {
    df %>%
      mutate(frac_total = coverage_fraction / sum(coverage_fraction)) %>%
      group_by(name, value) %>%
      summarize(freq = sum(frac_total))
  }, summarize_df = TRUE, include_cols = 'name', progress = FALSE)

I get the following error:

Error in .exact_extract(x, y, fun = fun, ..., include_xy = include_xy, : exact_extract was called with a function that does not appear to be of the form function(values, coverage_fractions, ...)

I have updated all my R packages, am using R version 4.0.4 and have just installed the recent package version from Github.

dbaston commented 3 years ago

Thanks for testing! Somehow the git version must not be installed, because the text of that error message is different now: https://github.com/isciences/exactextractr/blob/master/R/exact_extract.R#L382

RS-eco commented 3 years ago

Hm, I used github_install("isciences(exactextractr") and it says I have version 0.6.0 installed, which I believe to be the current version. I have just de-installed and re-installed the package again and I still get the same error message. However, using the CRAN version (0.5.1) I get the same error message. Could this be related to the compilation, when installing the package, as I am using a Linux/Ubuntu machine.

dbaston commented 3 years ago

Closing this issue as version 0.6.0 has been released and the vignettes are built correctly by CRAN.