1 ```#' Proportion held using reliable RAP formulation. ``` 2 ```#' ``` 3 ```#' This is a convenience function to quickly calculate the proportion of ``` 4 ```#' variation that one set of points captures in a another set of points using ``` 5 ```#' the reliable formulation. ``` 6 ```#' ``` 7 ```#' @param pu.coordinates [base::matrix()] of planning unit ``` 8 ```#' coordinates. ``` 9 ```#' ``` 10 ```#' @param pu.probabilities `numeric` vector of planning unit probabilities. ``` 11 ```#' ``` 12 ```#' @param dp.coordinates [base::matrix()] of demand point coordinates. ``` 13 ```#' ``` 14 ```#' @param dp.weights `numeric` vector of demand point weights. ``` 15 ```#' ``` 16 ```#' @param failure.distance `numeric` indicating the cost of the failure ``` 17 ```#' planning unit. ``` 18 ```#' ``` 19 ```#' @param maximum.r.level `integer` maximum failure (R) level to use for ``` 20 ```#' calculations. ``` 21 ```#' ``` 22 ```#' @return `numeric` value indicating the proportion of variation that the ``` 23 ```#' demand points explain in the planning units ``` 24 ```#' ``` 25 ```#' @examples ``` 26 ```#' rrap.proportion.held(as.matrix(iris[1:2,-5]), runif(1:2), ``` 27 ```#' as.matrix(iris[1:5,-5]), runif(1:5), 10) ``` 28 ```#' ``` 29 ```#' @export ``` 30 ```rrap.proportion.held <- function(pu.coordinates, pu.probabilities, ``` 31 ``` dp.coordinates, dp.weights, failure.distance, ``` 32 ``` maximum.r.level = ``` 33 ``` as.integer(length(pu.probabilities))) { ``` 34 ``` # data integreity checks ``` 35 5 ``` assertthat::assert_that(inherits(pu.coordinates, "matrix"), ``` 36 5 ``` is.numeric(pu.probabilities), ``` 37 5 ``` inherits(dp.coordinates, "matrix"), ``` 38 5 ``` is.numeric(dp.weights), ``` 39 5 ``` assertthat::is.scalar(failure.distance), ``` 40 5 ``` assertthat::is.count(maximum.r.level), ``` 41 5 ``` nrow(pu.coordinates) == length(pu.probabilities), ``` 42 5 ``` nrow(dp.coordinates) == length(dp.weights), ``` 43 5 ``` ncol(dp.coordinates) == ncol(pu.coordinates), ``` 44 5 ``` all(is.finite(c(dp.weights))), ``` 45 5 ``` all(is.finite(c(pu.probabilities))), ``` 46 5 ``` all(is.finite(c(pu.coordinates))), ``` 47 5 ``` all(is.finite(c(dp.coordinates))), ``` 48 5 ``` all(is.finite(c(failure.distance))), ``` 49 5 ``` all(is.finite(c(maximum.r.level))), ``` 50 5 ``` maximum.r.level <= nrow(pu.coordinates), ``` 51 5 ``` failure.distance >= 0, ``` 52 5 ``` nrow(pu.coordinates) >= 1, ``` 53 5 ``` nrow(dp.coordinates) >= 1) ``` 54 ``` # main processing ``` 55 5 ``` rcpp_rrap_proportion_held(pu.coordinates, pu.probabilities, dp.coordinates, ``` 56 5 ``` dp.weights, failure.distance, maximum.r.level) ``` 57 ```} ```

Read our documentation on viewing source code .