Commit 7b9e99f1 authored by Facundo Muñoz's avatar Facundo Muñoz ®️
Browse files

is.reciprocal(): fix example

parent a3e0a2a1
......@@ -7,14 +7,13 @@
#' @param x square numeric matrix or number
#'
#' @return logical
#'
#' @examples
#' Xf <- matrix(1:16, 4, 4)
#' Xr <- Xf
#' Xr[upper.tri(Xf)] <- 1/t(Xf)[upper.tri(Xf)]
#' diag(Xr) <- 1
#' is.reciprocal(Xf) # FALSE
#' is.reciprocal(Xr) # TRUE
#' mapMCDA:::is.reciprocal(Xf) # FALSE
#' mapMCDA:::is.reciprocal(Xr) # TRUE
is.reciprocal <- function(x) {
all(x * t(x) == 1)
}
......
......@@ -22,6 +22,6 @@ is 1 for all its elements.
Xr <- Xf
Xr[upper.tri(Xf)] <- 1/t(Xf)[upper.tri(Xf)]
diag(Xr) <- 1
is.reciprocal(Xf) # FALSE
is.reciprocal(Xr) # TRUE
mapMCDA:::is.reciprocal(Xf) # FALSE
mapMCDA:::is.reciprocal(Xr) # TRUE
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment