?apply ?which.max > m <- matrix(rnorm(12),nrow=4) > m > apply(m,1,which.max)
Petr bunny , lautloscrew.com napsal(a): > dear all, > > how can i get a vector that shows the number of the column of matrix > that contains the maximum of the row ?? > canĀ“t believe in need a loop for this... > > i have a 100 x 3 matrix and want to get a 100 x 1 vector with values > 1,2,3 . > > there must be a simple solution. i just cannot find it. i think am > searching on the wrong end. > > thx for help in advance. > > m. > > ______________________________________________ > R-help@stat.math.ethz.ch 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. > > -- Petr Klasterecky Dept. of Probability and Statistics Charles University in Prague Czech Republic ______________________________________________ R-help@stat.math.ethz.ch 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.