找回密码
 注册
查看: 4262|回复: 0

R语言:Matrix()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 20:25:30 | 显示全部楼层 |阅读模式
Matrix(Matrix)
Matrix()所属R语言包:Matrix

                                        Construct a Classed Matrix
                                         构建一个级矩阵

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Construct a Matrix of a class that inherits from Matrix.
构建一个矩阵继承Matrix的一类。


用法----------Usage----------


Matrix(data=NA, nrow=1, ncol=1, byrow=FALSE, dimnames=NULL,
       sparse = NULL, doDiag = TRUE, forceCheck = FALSE)



参数----------Arguments----------

参数:data
an optional numeric data vector or matrix.
一个可选的数字数据向量或矩阵。


参数:nrow
when data is not a matrix, the desired number of rows
当data是不是一个矩阵,所需的行数


参数:ncol
when data is not a matrix, the desired number of columns
当data是不是一个矩阵,所需的列数


参数:byrow
logical.  If FALSE (the default) the matrix is filled by columns, otherwise the matrix is filled by rows.
逻辑。如果FALSE(默认)矩阵列充满,否则矩阵按行填写。


参数:dimnames
a dimnames attribute for the matrix: a list of two character components.  They are set if not NULL (as per default).
dimnames属性矩阵:list两个字符组成。他们如果非NULL(按默认)。


参数:sparse
logical or NULL, specifying if the result should be sparse or not.  By default, it is made sparse when more than half of the entries are 0.  Note that when the resulting matrix is diagonal (“mathematically”), sparse=FALSE results in a diagonalMatrix, unless doDiag=FALSE as well, see the first examples.
逻辑或NULL,如果指定的结果应该是稀疏或不。默认情况下,它是由稀疏时,超过一半的作品都为0。请注意,当矩阵是对角线(“数学”),sparse=FALSE结果diagonalMatrix,除非doDiag=FALSE以及,看到的第一个例子。


参数:doDiag
only when sparse = FALSE, logical indicating if a diagonalMatrix object should be considered (default).  Otherwise, in such a case, a dense (symmetric) matrix will be returned.
只有当sparse = FALSE,逻辑表明,如果一个diagonalMatrix对象,应考虑(默认)。否则,在这种情况下,密集的(对称)矩阵将被退回。


参数:forceCheck
logical indicating if the checks for structure should even happen when data is already a "Matrix" object.
逻辑表明,如果结构的检查,甚至发生时data已"Matrix"对象。


Details

详情----------Details----------

If either of nrow or ncol is not given, an attempt is made to infer it from the length of data and the other parameter. Further, Matrix() makes efforts to keep logical matrices logical, i.e., inheriting from class lMatrix, and to determine specially structured matrices such as symmetric, triangular or diagonal ones.  Note that a symmetric matrix also needs symmetric dimnames, e.g., by specifying dimnames = list(NULL,NULL), see the examples.
如果nrow或ncol没有给出任何企图从data和其他参数的长度来推断它。此外,Matrix()努力保持logical矩阵的逻辑,即,从类继承lMatrix,并确定特殊结构,如对称,三角形或对角线的矩阵。请注意,对称矩阵也需要对称dimnames,例如,通过指定dimnames = list(NULL,NULL),看到的例子。

Most of the time, the function works via a traditional (full) matrix.  However, Matrix(0, nrow,ncol) directly constructs an “empty” sparseMatrix, as does Matrix(FALSE, *).
大部分时间,功能可以通过传统的(全)的matrix。然而,Matrix(0, nrow,ncol)直接构造一个“空”sparseMatrix的,Matrix(FALSE, *)。

Although it is sometime possible to mix unclassed matrices (created with matrix) with ones of class "Matrix", it is much safer to always use carefully constructed ones of class "Matrix".
虽然它是一段混合的类matrix unclassed矩阵("Matrix"创建),它是更安全始终使用类"Matrix"精心构造的。


值----------Value----------

Returns matrix of a class that inherits from "Matrix". Only if data is not a matrix and does not already inherit from class Matrix are the arguments nrow, ncol and byrow made use of.
返回矩阵继承一个类,从"Matrix"。只有data不matrix不已经从类继承Matrix参数nrow,ncol和byrow使用。


参见----------See Also----------

The classes Matrix, symmetricMatrix, triangularMatrix, and diagonalMatrix; further, matrix.
类Matrix,symmetricMatrix,triangularMatrix,diagonalMatrix;进一步,matrix。

Special matrices can be constructed, e.g., via sparseMatrix (sparse), bdiag (block-diagonal), bandSparse (banded sparse), or Diagonal.
可以构造特殊矩阵,例如,通过sparseMatrix(稀疏),bdiag(块对角),bandSparse(带状稀疏),或Diagonal。


举例----------Examples----------


Matrix(0, 3, 2)             # 3 by 2 matrix of zeros -> sparse[3 2零 - >稀疏矩阵]
Matrix(0, 3, 2, sparse=FALSE)# -> 'dense'[ - >密]
Matrix(0, 2, 2, sparse=FALSE)# diagonal ![对角线!]
Matrix(0, 2, 2, sparse=FALSE, doDiag=FALSE)# -> dense[ - >密]
Matrix(1:6, 3, 2)           # a 3 by 2 matrix (+ integer warning)[一个3×2矩阵(整数警告)]
Matrix(1:6 + 1, nrow=3)

## logical ones:[#逻辑的:]
Matrix(diag(4) >  0)# -> "ldiMatrix" with diag = "U"[ - >“ldiMatrix”与诊断的“U”]
Matrix(diag(4) >  0, sparse=TRUE)# -> sparse...[ - >稀疏...]
Matrix(diag(4) >= 0)# -> "lsyMatrix" (of all 'TRUE')[ - >“lsyMatrix”(所有“TRUE”)]
## triangular[#三角]
l3 <- upper.tri(matrix(,3,3))
(M &lt;- Matrix(l3))  # -&gt; "ltCMatrix"[ - >“ltCMatrix”]
Matrix(! l3)# -&gt; "ltrMatrix"[ - >“ltrMatrix”]
as(l3, "CsparseMatrix")

Matrix(1:9, nrow=3,
       dimnames = list(c("a", "b", "c"), c("A", "B", "C")))
(I3 &lt;- Matrix(diag(3)))# identity, i.e., unit "diagonalMatrix"[身份,即单位“diagonalMatrix”]
str(I3) # note the empty 'x' slot[注意空槽X]

(A &lt;- cbind(a=c(2,1), b=1:2))# symmetric *apart* from dimnames[对称*除*从dimnames]
Matrix(A)                    # hence 'dgeMatrix'[因此,“dgeMatrix”]
(As &lt;- Matrix(A, dimnames = list(NULL,NULL)))# -&gt; symmetric[ - >对称]
stopifnot(is(As, "symmetricMatrix"),
          is(Matrix(0, 3,3), "sparseMatrix"),
          is(Matrix(FALSE, 1,1), "sparseMatrix"))

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-1-24 15:18 , Processed in 0.024670 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表