Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
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 |
assertthat::assert_that(inherits(x, "matrix"), |
|
24 |
inherits(y, "matrix"), |
|
25 |
is.numeric(y.weights), |
|
26 |
nrow(y) == length(y.weights), |
|
27 |
ncol(x) == ncol(y), |
|
28 |
all(is.finite(c(x))), |
|
29 |
all(is.finite(c(y))), |
|
30 |
all(is.finite(c(y.weights))), |
|
31 |
all(y.weights >= 0), |
|
32 |
nrow(x) >= 1, |
|
33 |
nrow(y) >= 1) |
|
34 |
rcpp_proportion_held(x, y, y.weights) |
|
35 |
}
|
Read our documentation on viewing source code .