For an old timer who had been doing some 2-D image processing stuff, the implementation below that simply gets the minimum of the upper half of the diagonal would be more recognizable
mind <- function(mt)
{
size = nrow(mt)
min = max(mt[1,]) # simple initialization. can be set to any value other than the diagonal elements
cities = c(NULL, NULL)
for(r in 1:(size-1))
{
for(c in (r+1):size)
if(mt[r,c]<min)
{ min=mt[r,c]
cities = c(r,c)
}
}
return(c(min, cities))
}
'Learning & Reasoning > R ' 카테고리의 다른 글
R datatype 간단 정리 (0) | 2013.02.20 |
---|---|
6.3.2 Extended Example: Extracting a Subtable "The Art of R Programming" (0) | 2013.02.15 |
Erratum in "The art of R programming" Chapter 2 - abalone.data (1) | 2013.02.11 |
Erratum in "The art of R programming" (0) | 2013.02.08 |
vector라 불리는 R 자료구조 (0) | 2013.02.06 |