diag(spam)
diag()所属R语言包:spam
Sparse Matrix diagonals
稀疏矩阵的对角化
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Extract or replace the diagonal of a matrix, or construct a diagonal matrix.
提取或取代的对角矩阵,或构建一个对角矩阵。
用法----------Usage----------
# diag(x)
diag(x=1, nrow, ncol)
diag(x) <- value
diag.spam(x=1, nrow, ncol)
diag.spam(x) <- value
参数----------Arguments----------
参数:x
a spam matrix, a vector or a scalar.
spam矩阵,向量或标量。
参数:nrow, ncol
Optional dimensions for the result.
可选尺寸的结果。
参数:value
either a single value or a vector of length equal to that of the current diagonal.
一个单一的值或等于当前的对角线的长度的矢量。
Details
详细信息----------Details----------
Using diag(x) can have unexpected effects if x is a vector that could be of length one. Use diag(x, nrow = length(x)) for consistent behaviour.
使用diag(x)可以有意想不到的效果,如果x是一个向量,可以是长度为一。使用diag(x, nrow = length(x))一致的行为。
值----------Value----------
If x is a spam matrix then diag(x) returns the diagonal of x.
如果x是垃圾邮件矩阵,然后diag(x)返回的对角线x。
The assignment form sets the diagonal of the sparse matrix x to the given value(s).<br>
分配的形式设置对角稀疏矩阵x给定的值(S)。<BR>
diag.spam works as diag for spam matrices: If x is a vector (or 1D array) of length two or more, then diag.spam(x) returns a diagonal matrix whose diagonal is x.
diag.spam diag的垃圾邮件矩阵:x如果是一个向量的长度(或一维数组)两个或两个以上,那么diag.spam(x)返回一个对角矩阵,其对角线为x。
If x is a vector of length one then diag.spam(x) returns an identity matrix of order the nearest integer to x. The dimension of the returned matrix can be specified by nrow and ncol (the default is square).
如果x是一个向量的长度为一diag.spam(x)返回一个单位矩阵的顺序最接近的整数x。返回的矩阵的尺寸可以指定nrow和ncol(默认情况下是方形的)。
The assignment form sets the diagonal of the matrix x to the given value(s).
设置对角矩阵的x给定的值(S)的分配形式。
(作者)----------Author(s)----------
Reinhard Furrer
参见----------See Also----------
upper.tri, lower.tri.
upper.tri,lower.tri。
实例----------Examples----------
diag.spam(2, 4) # 2*I4[2 * I4]
smat <- diag.spam(1:5)
diag( smat)
diag( smat) <- 5:1
# The last line is equivalent to [最后一行是相当于]
diag.spam( smat) <- 5:1
# Note that diag.spam( 1:5) <- 5:1 not work of course.[需要注意的是diag.spam(1:5)< - 5点01分,当然工作。]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|