compute_eigen_centr_period <- function(.graph,
.year_start, .year_end,
.only_active_places = T,
.only_n_past_exh = NULL,
.set_centrality_NA_if_inactive = T,
.lower_boundary_year,
.output_as_nodes_df_long = F){
# .graph = galsimple
# .year_start <- 1915
# .year_end <- 2017
# .lower_boundary_year <- 1900
# .set_centrality_NA_if_inactive = T
# .only_n_past_exh = 5
graph.eigen <- .graph %>%
tidygraph::as_tbl_graph() %>%
tidygraph::mutate(name = as.integer(name))
years <- seq(.year_start, .year_end, 1)
for(i in 1:length(years)){
df <- compute_centr_year(.graph,
.yr_centr_computed = years[i],
.lower_boundary_yr = .lower_boundary_year,
.only_active_place = .only_active_places,
.only_n_past_exh = .only_n_past_exh,
.set_centrality_NA_if_inactive = .set_centrality_NA_if_inactive,
.output_as_nodes_df = T)
graph.eigen <- graph.eigen %>%
tidygraph::activate(nodes) %>%
tidygraph::left_join(df, by = "name")
}
if(.output_as_nodes_df_long == T){
value_col_name <- if_else(is.null(.only_n_past_exh),
"eigen_past_all_exh",
paste0("eigen_past", .only_n_past_exh, "_exh"))
graph.eigen.df <- graph.eigen %>%
igraph::as_data_frame("vertices") %>%
select(., name, contains("eigen_")) %>%
tidyr::gather(., var, val, - name) %>%
mutate(year = var %>% str_extract("[0-9]{4}") %>% as.integer()) %>%
select(- var)
colnames(graph.eigen.df)[2] <- value_col_name
return(graph.eigen.df)
}
return(graph.eigen)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.