Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding .by to ww_multi_scale() #35

Open
mikemahoney218 opened this issue Apr 24, 2023 · 0 comments
Open

Consider adding .by to ww_multi_scale() #35

mikemahoney218 opened this issue Apr 24, 2023 · 0 comments

Comments

@mikemahoney218
Copy link
Member

dplyr functions (including summarise() and mutate(), among others) now have an argument, .by, which allows for per-operation grouping, removing the need for group_by() in simple pipelines. It'd be nice for ww_multi_scale() to support the same (for the sf method; raster methods don't support grouping, and probably never will), such that these calls were equivalent:

ww_multi_scale(
      dplyr::group_by(ames_sf, Neighborhood),
      Sale_Price,
      predictions,
      n = list(
        c(10, 10),
        c(1, 1)
      ),
      square = FALSE
    )
ww_multi_scale(
      ames_sf,
      Sale_Price,
      predictions,
      n = list(
        c(10, 10),
        c(1, 1)
      ),
      square = FALSE,
    .by = Neighborhood
    )

For what it's worth, note that dplyr errors when trying to mix group_by() and .by:

> dplyr::group_by(iris, Species) |> dplyr::summarise(m = mean(Sepal.Length), .by = Species)
Error in `dplyr::summarise()`:
! Can't supply `.by` when `.data` is a grouped data frame.
Run `rlang::last_trace()` to see where the error occurred.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant