Hi,

I'm a new user. I've been reading through the manual and looking at
various examples but am still trying to make sense of the most
efficient ways to handle matrices of data.

If I have a 2D matrix of data, how do I get the mean, min, max value
of each row?  I see the "mean" function on a matrix will give me
averages by row, but min and max give me the value for the entire
matrix.  I want the min (for example) of each row.  pmin looks useful,
but I can't seem to get the syntax right to apply to each column.

Right now I am doing this.  Is there a one-liner that would work instead?

minResult <- vector (mode="list", length=rowCount)
for (row in 1:rowCount)
{
        minResult[[row]] <- min(corResult[row], na.rm = TRUE)                   
}

Thanks in advance.

WILL

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to