1
#' Proportion held using unreliable 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 unreliable formulation.
6
#'
7
#' @param x [base::matrix()] of points
8
#'
9
#' @param y [base::matrix()] of points
10
#'
11
#' @param y.weights `numeric` vector of weights for each point in
12
#'   `y`. Defaults to equal weights for all points in `y`.
13
#'
14
#' @return `numeric` value indicating the proportion of variation that
15
#'   `x` explains in `y`
16
#'
17
#' @examples
18
#' urap.proportion.held(as.matrix(iris[1:2,-5]), as.matrix(iris[1:5,-5]))
19
#'
20
#' @export
21
urap.proportion.held <- function(x, y, y.weights = rep(1, nrow(y))) {
22
  # data integrity checks
23 5
  assertthat::assert_that(inherits(x, "matrix"),
24 5
                          inherits(y, "matrix"),
25 5
                          is.numeric(y.weights),
26 5
                          nrow(y) == length(y.weights),
27 5
                          ncol(x) == ncol(y),
28 5
                          all(is.finite(c(x))),
29 5
                          all(is.finite(c(y))),
30 5
                          all(is.finite(c(y.weights))),
31 5
                          all(y.weights >= 0),
32 5
                          nrow(x) >= 1,
33 5
                          nrow(y) >= 1)
34 5
  rcpp_proportion_held(x, y, y.weights)
35
}

Read our documentation on viewing source code .

Loading