[S] predict.tree with tssa object

Tim Hesterberg (timh@statsci.com)
Thu, 9 Jul 1998 09:15:40 -0700 (PDT)


>Given a vector, I know how to find out its maximum value.
>How can I determine which element of the vector is that maximum ?
>
>e.g
>
>max(v) <- v[?]

first.max <- function(x)
((1:length(x))[x == max(x)])[1]

first.min <- function(x)
((1:length(x))[x == min(x)])[1]

Also, for matrices:

mat.first.max <- function(x)
{
i <- first.max(x)
c(row(x)[i], col(x)[i])
}

mat.first.min <- function(x)
{
i <- first.min(x)
c(row(x)[i], col(x)[i])
}

Tim Hesterberg
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news