I have a matrix with 50 rows and 50 columns:
[,1] [,2] [,3]...[,50]
[1,]    1    0.8    0.7
[2,]    0.8    1    0.5
[3,]    0.7    0.5    1
...
[50,]
And I want to sum 0.02 in values up to diagonal to obtain something like this:
[,1] [,2] [,3]...[,50]
[1,]    1    0.82    0.72
[2,]    0.8    1    0.52
[3,]    0.7    0.5    1
...
[50,]
Does anyone know how the sum could be done only in the values that are above the diagonal of the matrix using R?
Example of matrix code:
matrix <- as.matrix(data.frame(A = c(1, 0.8, 0.7), B = c(0.8, 1, 0.5), C = c(0.7, 0.5, 1)), nrow=3, ncol=3)
 
     
    