rowMaxs.sirt(matr) # rowwise maximum
rowMins.sirt(matr) # rowwise minimum
rowCumsums.sirt(matr) # rowwise cumulative sum
colCumsums.sirt(matr) # columnwise cumulative sum
rowIntervalIndex.sirt(matr,rn) # first index in row nn when matr(nn,zz) > rn(nn)
rowKSmallest.sirt(matr , K , break.ties=TRUE) # k smallest elements in a row
rowKSmallest2.sirt(matr , K )
TRUE
.rowMaxs.sirt
is a list with the elements
maxval
(rowwise maximum values) and maxind
(rowwise
maximum indices). The output of rowMins.sirt
contains
corresponding minimum values with entries minval
and
minind
.
The output of rowKSmallest.sirt
are two matrices:
smallval
contains the $K$ smallest values whereas
smallind
contains the $K$ smallest indices.rowIntervalIndex.sirt
searches for all rows n
the first index i
for which matr(n,i) > rn(n)
holds.
The functions rowKSmallest.sirt
and rowKSmallest2.sirt
extract the $K$ smallest entries in a matrix row. For small
numbers of $K$ the function rowKSmallest2.sirt
is
the faster one.#############################################################################
# EXAMPLE 1: a small toy example (I)
#############################################################################
set.seed(789)
N1 <- 10 ; N2 <- 4
M1 <- round( matrix( runif(N1*N2) , nrow=N1 , ncol=N2) , 1 )
rowMaxs.sirt(M1) # rowwise maximum
rowMins.sirt(M1) # rowwise minimum
rowCumsums.sirt(M1) # rowwise cumulative sum
# row index for exceeding a certain threshold value
matr <- M1
matr <- matr / rowSums( matr )
matr <- rowCumsums.sirt( matr )
rn <- runif(N1) # generate random numbers
rowIntervalIndex.sirt(matr,rn)
# select the two smallest values
rowKSmallest.sirt(matr=M1 , K=2)
rowKSmallest2.sirt(matr=M1 , K=2)
Run the code above in your browser using DataLab