Search notes:

R function: upper.tri

#
#   S.a. -> lower.tri
#

m <- matrix ( rep(42, 7*5),
              nrow = 5)

m
#      [,1] [,2] [,3] [,4] [,5] [,6] [,7]
# [1,]   42   42   42   42   42   42   42
# [2,]   42   42   42   42   42   42   42
# [3,]   42   42   42   42   42   42   42
# [4,]   42   42   42   42   42   42   42
# [5,]   42   42   42   42   42   42   42

cat("\n\n")

upper.tri(m)
#       [,1]  [,2]  [,3]  [,4]  [,5] [,6] [,7]
# [1,] FALSE  TRUE  TRUE  TRUE  TRUE TRUE TRUE
# [2,] FALSE FALSE  TRUE  TRUE  TRUE TRUE TRUE
# [3,] FALSE FALSE FALSE  TRUE  TRUE TRUE TRUE
# [4,] FALSE FALSE FALSE FALSE  TRUE TRUE TRUE
# [5,] FALSE FALSE FALSE FALSE FALSE TRUE TRUE

cat("\n\n")

m[upper.tri(m)] = 0
m
#      [,1] [,2] [,3] [,4] [,5] [,6] [,7]
# [1,]   42    0    0    0    0    0    0
# [2,]   42   42    0    0    0    0    0
# [3,]   42   42   42    0    0    0    0
# [4,]   42   42   42   42    0    0    0
# [5,]   42   42   42   42   42    0    0
Github repository about-r, path: /functions/upper.tri.R

See also

Index to (some) R functions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758201009, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/upper_tri(73): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78