1 ```#' @title Rank interval of nodes ``` 2 ```#' @description Calculate the maximal and minimal rank possible for each node ``` 3 ```#' in any ranking that is in accordance with the partial ranking `P`. ``` 4 ```#' @param P A partial ranking as matrix object calculated with [neighborhood_inclusion] ``` 5 ```#' or [positional_dominance]. ``` 6 ```#' @details Note that the returned `mid_point` is not the same as the expected ``` 7 ```#' rank, for instance computed with [exact_rank_prob]. ``` 8 ```#' It is simply the average of `min_rank` and `max_rank`. For exact rank probabilities ``` 9 ```#' use [exact_rank_prob]. ``` 10 ```#' @return A data frame with the minimal, maximal rank of each node together ``` 11 ```#' with the mid point of the two extrema. ``` 12 ```#' @author David Schoch ``` 13 ```#' @seealso [plot_rank_intervals], [exact_rank_prob] ``` 14 ```#' ``` 15 ```#' @examples ``` 16 ```#' P <- matrix(c(0,0,1,1,1,0,0,0,1,0,0,0,0,0,1,rep(0,10)),5,5,byrow=TRUE) ``` 17 ```#' rank_intervals(P) ``` 18 ```#' @export ``` 19 ```rank_intervals <- function(P) { ``` 20 1 ``` n <- nrow(P) ``` 21 1 ``` max_rank_all <- n - rowSums((P - t(P)) == 1) - rowSums(P == 1 & t(P) == 1) #CAUTION!!!! ``` 22 1 ``` min_rank_all <- colSums((P - t(P)) == 1) + 1 ``` 23 1 ``` mid_point_all <- (max_rank_all + min_rank_all)/2 ``` 24 ``` ``` 25 1 ``` return(data.frame(min_rank = min_rank_all, ``` 26 1 ``` max_rank = max_rank_all, ``` 27 1 ``` mid_point = mid_point_all)) ``` 28 ```} ```

Read our documentation on viewing source code .