Skip to content

Commit

Permalink
Update function_brnet.R
Browse files Browse the repository at this point in the history
  • Loading branch information
aterui committed Oct 17, 2020
1 parent 0f1c8bb commit d8ff5cf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions R/function_brnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,13 @@ brnet <- function(n_patch,
v_distance_to_root <- m_distance[1, ]

df_asymmetry <- expand.grid(patch1 = seq_len(n_patch), patch2 = seq_len(n_patch)) %>%
dplyr::mutate(d1 = v_distance_to_root[.data$patch1],
d2 = v_distance_to_root[.data$patch2]) %>%
dplyr::mutate(delta = .data$d2 - .data$d1,
distance = m_distance[cbind(.data$patch1, .data$patch2)]) %>%
dplyr::mutate(x = 0.5 * (.data$distance - .data$delta)) %>%
dplyr::mutate(weighted_distance = (1 + asymmetry_factor) * .data$x + asymmetry_factor * .data$delta) %>%
dplyr::filter(.data$patch1 != .data$patch2)
dplyr::mutate(d1 = v_distance_to_root[.data$patch1],
d2 = v_distance_to_root[.data$patch2]) %>%
dplyr::mutate(delta = .data$d2 - .data$d1,
distance = m_distance[cbind(.data$patch1, .data$patch2)]) %>%
dplyr::mutate(x = 0.5 * (.data$distance - .data$delta)) %>%
dplyr::mutate(weighted_distance = (1 + asymmetry_factor) * .data$x + asymmetry_factor * .data$delta) %>%
dplyr::filter(.data$patch1 != .data$patch2)

m_weighted_distance <- m_distance
m_weighted_distance[cbind(df_asymmetry$patch1, df_asymmetry$patch2)] <- df_asymmetry$weighted_distance
Expand Down

0 comments on commit d8ff5cf

Please sign in to comment.