The R Project SVN R

Rev

Rev 73030 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 73030 Rev 90063
Line 1... Line 1...
1
% File src/library/base/man/lower.tri.Rd
1
% File src/library/base/man/lower.tri.Rd
2
% Part of the R package, https://www.R-project.org
2
% Part of the R package, https://www.R-project.org
3
% Copyright 1995-2017 R Core Team
3
% Copyright 1995-2026 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{lower.tri}
6
\name{lower.tri}
7
\alias{lower.tri}
7
\alias{lower.tri}
8
\alias{upper.tri}
8
\alias{upper.tri}
Line 19... Line 19...
19
  \item{x}{a matrix or other \R object with \code{length(dim(x)) == 2}.
19
  \item{x}{a matrix or other \R object with \code{length(dim(x)) == 2}.
20
    For back compatibility reasons, when the above is not fulfilled,
20
    For back compatibility reasons, when the above is not fulfilled,
21
    \code{\link{as.matrix}(x)} is called first.}
21
    \code{\link{as.matrix}(x)} is called first.}
22
  \item{diag}{logical.  Should the diagonal be included?}
22
  \item{diag}{logical.  Should the diagonal be included?}
23
}
23
}
-
 
24
\details{
-
 
25
  Note that \code{!lower.tri(x)} gives the same as \code{upper.tri(x, diag=TRUE)}, and
-
 
26
  analogously, \code{!upper.tri(x)} is equivalent to \code{lower.tri(x, diag=TRUE)},
-
 
27
  and the \code{diag=TRUE} versions are very slightly more efficient.
-
 
28
}
24
\seealso{
29
\seealso{
25
  \code{\link{diag}}, \code{\link{matrix}}; further \code{\link{row}}
30
  \code{\link{diag}}, \code{\link{matrix}}; further \code{\link{.row}}
26
  and \code{\link{col}} on which \code{lower.tri()} and
31
  and \code{\link{.col}} on which \code{lower.tri()} and
27
  \code{upper.tri()} are built.
32
  \code{upper.tri()} are built.
28
}
33
}
29
\examples{
34
\examples{
30
(m2 <- matrix(1:20, 4, 5))
35
(m2 <- matrix(1:20, 4, 5))
31
lower.tri(m2)
36
lower.tri(m2)
32
m2[lower.tri(m2)] <- NA
37
m2[lower.tri(m2)] <- NA
33
m2
38
m2
-
 
39
 
-
 
40
## "prove" equivalence   lower.tri  <---> !upper.tri
-
 
41
set.seed(12)
-
 
42
for(i in 1:99) {
-
 
43
    x <- matrix(as.integer(64*rnorm(6*4)), 6, 4)
-
 
44
    stopifnot(identical( !lower.tri(x), upper.tri(x, diag=TRUE)),
-
 
45
              identical( !upper.tri(x), lower.tri(x, diag=TRUE)))
-
 
46
 }
34
}
47
}
35
\keyword{array}
48
\keyword{array}