Compute the orthogonal complement of a subspace
nullComplement.RdComputes the orthogonal complement of a subspace relative to a universe.
Details
null_complement computes the orthogonal complement of a
  subspace (spanned by the columns of m) relative to a universe.
Argument universe can be used to specify a subspace w.r.t.
  which to compute the complement.  If universe is NULL
  (the default), the complement w.r.t. the full space is computed. The
  full space is the \(n\)-dimensional space, where \(n\) is the
  number of rows of argument m.
null_complement returns a matrix whose columns give a basis of
  the required subspace.
null_complement uses Null() from package MASS for the
  actual computation. null_complement(m, na.allow = FALSE) is
  equivalent to Null(m).
m is typically a matrix whose columns represent the subspace
  w.r.t. which to compute the complement.
  null_complement can also deal with NA's in m. This
  facility can be turned off by specifying na.allow = FALSE.
If na.allow = TRUE, the default, and m is identical to
  NA, universe is returned (i.e. m = NA represents
  the empty subspace). Note that in this case universe cannot be
  NULL, since there is no way to determine the dimension of the full
  space.
Otherwise, m is a matrix. If all elements of m are
  NA, a matrix of NA's is returned with number of columns equal
  to ncol(universe) - ncol(m).
Examples
m1 <- diag(1, nrow = 3, ncol = 2)
null_complement(m1)
#>      [,1]
#> [1,]    0
#> [2,]    0
#> [3,]    1
null_complement(c(1,1,0))
#>            [,1] [,2]
#> [1,] -0.7071068    0
#> [2,]  0.7071068    0
#> [3,]  0.0000000    1
null_complement(c(1,1,0), m1)
#>            [,1]
#> [1,]  0.7071068
#> [2,] -0.7071068
#> [3,]  0.0000000
## the columns of the result from null_complement() are orthogonal
## to  the 1st argument:
t(c(1,1,0)) %*% null_complement(c(1,1,0))
#>              [,1] [,2]
#> [1,] 1.110223e-16    0
t(c(1,1,0)) %*% null_complement(c(1,1,0), m1)
#>               [,1]
#> [1,] -1.110223e-16
null_complement(rep(NA_real_, 3), m1)
#>      [,1]
#> [1,]   NA
#> [2,]   NA
#> [3,]   NA
null_complement(NA, m1)
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> [3,]    0    0