Hi there, if I understand you correctly, you want to return the minimum value for each column of your gauss.filter
matrix?
If so, I would suggest using the apply()
function. As the name suggests, this function applies a function over a margin of a matrix like object. It would look something like this:
a <- c(1, 4, 6, 4, 1)
b <- c(4, 16, 24, 16, 4)
c <- c(6, 24, 36, 24, 6)
d <- c(4, 16, 24, 16, 4)
e <- c(1, 4, 6, 4, 1)
gauss.filter <- cbind(a, b, c, d, e)
apply(
X = gauss.filter,
MARGIN = 2,
FUN = min
)
#> a b c d e
#> 1 4 6 4 1
The apply
function above can be read as, "return the minimum value of each column of the gauss.filter
matrix." (If MARGIN
had been set to 1, it would have returned the minum value for each row instead of each column.
As an aside, I would strongly suggest taking a look at this post which has a few solid resources for learning R. Good luck!