maxCol(base)
maxCol()所属R语言包:base
Find Maximum Position in Matrix
在矩阵的最大位置
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Find the maximum position for each row of a matrix, breaking ties at random.
求矩阵的每一行的最高位置,打破随机的关系。
用法----------Usage----------
max.col(m, ties.method=c("random", "first", "last"))
参数----------Arguments----------
参数:m
numerical matrix
数值矩阵
参数:ties.method
a character string specifying how ties are handled, "random" by default; can be abbreviated; see "Details".
一个字符串,指定如何处理关系,"random"默认情况下,可以略见“详细资料”。
Details
详情----------Details----------
When ties.method = "random", as per default, ties are broken at random. In this case, the determination of a tie assumes that the entries are probabilities: there is a relative tolerance of 1e-5, relative to the largest (in magnitude, omitting infinity) entry in the row.
当ties.method = "random",为默认,关系破裂随机。在这种情况下,领带的决心,承担该项目是概率:1e-5,相对最大(大小,省略无穷大)的行中的条目有一个相对宽容。
If ties.method = "first", max.col returns the column number of the first of several maxima in every row, the same as unname(apply(m, 1, which.max)).<br> Correspondingly, ties.method = "last" returns the last of possibly several indices.
如果ties.method = "first",max.col返回在每一行的第一个数的最大值,同样作为unname(apply(m, 1, which.max))。参考相应的列数,ties.method = "last"返回最后可能几个指标。
值----------Value----------
index of a maximal value for each row, an integer vector of length nrow(m).
指数每行的最大价值,整数向量的长度nrow(m)。
参考文献----------References----------
Modern Applied Statistics with S. New York: Springer (4th ed).
参见----------See Also----------
which.max for vectors.
which.max的向量。
举例----------Examples----------
table(mc <- max.col(swiss))# mostly "1" and "5", 5 x "2" and once "4"[大多是“1”和“5”,5×2“和一次”4“]
swiss[unique(print(mr <- max.col(t(swiss)))) , ] # 3 33 45 45 33 6[3 33 45 45 33 6]
set.seed(1)# reproducible example:[重复的例子:]
(mm <- rbind(x = round(2*stats::runif(12)),
y = round(5*stats::runif(12)),
z = round(8*stats::runif(12))))
## Not run: [#无法运行:]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
x 1 1 1 2 0 2 2 1 1 0 0 0
y 3 2 4 2 4 5 2 4 5 1 3 1
z 2 3 0 3 7 3 4 5 4 1 7 5
## End(Not run)[#结束(不运行)]
## column indices of all row maxima :[#列的所有行极大的指标:]
utils::str(lapply(1:3, function(i) which(mm[i,] == max(mm[i,]))))
max.col(mm) ; max.col(mm) # "random"[“随机”]
max.col(mm, "first")# -> 4 6 5[ - > 4 6 5]
max.col(mm, "last") # -> 7 9 11[ - > 7 9 11]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|