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 utility function to provide summaries of multiple variables #52

Open
JosiahParry opened this issue Mar 27, 2024 · 3 comments
Open

Comments

@JosiahParry
Copy link
Owner

Semi-working idea

library(sfdep)
library(tidyverse)

guerry |> 
  mutate(
    nb = st_contiguity(geometry),
    wt = st_weights(nb)
  ) |> 
  sf::st_drop_geometry() |> 
  summarise(
    avg = mean(crime_pers),
    std_dev = sd(crime_pers),
    I = list(broom::tidy(global_moran_perm(crimea_pers, nb, wt)))
  ) |> 
  tidyr::unnest_wider(I) |> 
  knitr::kable()

summarise_var <- function(x, nb, wt) {
  tibble::tibble(
    avg = mean(x),
    std_dev = sd(x),
    I = list(broom::tidy(global_moran_perm(x, nb, wt)))
  ) |> 
    tidyr::unnest(I)
}

summarize_all_vars <- function(x, nb, wt) {
  lapply(x, summarise_var, nb, wt) |> 
    collapse::rowbind()
}
@DHLocke
Copy link
Collaborator

DHLocke commented Mar 27, 2024 via email

@DHLocke
Copy link
Collaborator

DHLocke commented Mar 27, 2024 via email

@DHLocke
Copy link
Collaborator

DHLocke commented Apr 18, 2024 via email

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

2 participants