formatSparseM(Matrix)
formatSparseM()所属R语言包:Matrix
Formatting Sparse Numeric Matrices Utilities
格式化稀疏的数字矩阵公用事业
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Utilities for formatting sparse numeric matrices in a flexible way. These functions are used by the format and print methods for sparse matrices and can be applied as well to standard R matrices. Note that all arguments but the first are optional.
实用程序格式化稀疏数字矩阵,以灵活的方式。这些功能都使用format和print稀疏矩阵的方法,可以应用,以及标准的R矩阵。请注意,所有参数,但首先是可选的。
formatSparseM() is the main “workhorse” of formatSpMatrix, the format method for sparse matrices.
formatSparseM()是主要的“主力”formatSpMatrix,format稀疏矩阵的方法。
.formatSparseSimple() is a simple helper function, also dealing with (short/empty) column names construction.
.formatSparseSimple()是一个简单的辅助功能,还与处理(短/空)列名建设。
用法----------Usage----------
formatSparseM(x, zero.print = ".", align = c("fancy", "right"),
m = as(x,"matrix"), asLogical=NULL, digits=NULL,
cx, iN0, dn = dimnames(m))
.formatSparseSimple(m, asLogical=FALSE, digits=NULL,
col.names, note.dropping.colnames = TRUE,
dn=dimnames(m))
参数----------Arguments----------
参数:x
an R object inheriting from class sparseMatrix.
继承类sparseMatrixR对象。
参数:zero.print
character which should be used for structural zeroes. The default "." may occasionally be replaced by " " (blank); using "0" would look almost like print()ing of non-sparse matrices.
字符而应当用于结构性零。有时可能会被替换默认"."" "(空);使用"0"看起来几乎像print()ING非稀疏矩阵。
参数:align
a string specifying how the zero.print codes should be aligned, see formatSpMatrix.
一个字符串,指定如何应对准zero.print代码,看到formatSpMatrix。
参数:m
(optional) a (standard R) matrix version of x.
(可选)(标准R)matrixx版本。
参数:asLogical
should the matrix be formatted as a logical matrix (or rather as a numeric one); mostly for formatSparseM().
应被格式化为一个逻辑矩阵(或者更确切地说,作为一个数字);大多为formatSparseM()矩阵。
参数:digits
significant digits to use for printing, see print.default.
用于打印的有效位数,看到print.default。
参数:cx
(optional) character matrix; a formatted version of x, still with strings such as "0.00" for the zeros.
(可选)字符点阵;x格式化版本,依然如"0.00"零字符串。
参数:iN0
(optional) integer vector, specifying the location of the non-zeroes of x.
(可选)整数向量,指定非x零的位置。
参数:col.names, note.dropping.colnames
see formatSpMatrix.
看到formatSpMatrix。
参数:dn
dimnames to be used; a list (of length two) with row and column names (or NULL).
dimnames要使用的行和列名(或NULL)名单;(长度二)。
值----------Value----------
a character matrix like cx, where the zeros have been replaced with (padded versions of) zero.print. As this is a dense matrix, do not use these functions for really large (really) sparse matrices!
一个字符矩阵像cx,zero.print(软垫版本)已取代零。由于这是一个致密的基质,不使用这些功能,真正的大(真)稀疏矩阵!
作者(S)----------Author(s)----------
Martin Maechler
参见----------See Also----------
formatSpMatrix which calls formatSparseM() and is the format method for sparse matrices.<br> printSpMatrix which is used by the (typically implicitly called) show and print methods for sparse matrices.
formatSpMatrix要求formatSparseM()和format稀疏矩阵的方法。参考printSpMatrix这是用来(通常是隐式调用)show和 print稀疏矩阵的方法。
举例----------Examples----------
m <- suppressWarnings(matrix(c(0, 3.2, 0,0, 11,0,0,0,0,-7,0), 4,9))
fm <- formatSparseM(m)
noquote(fm)
## nice, but this is nicer :[#不错,但这个更佳:]
print(fm, quote=FALSE, right=TRUE)
## and "the same" as :[#和“同”:]
Matrix(m)
## align = "right" is cheaper --> the "." are not aligned:[#对齐=“正确的”便宜 - “”>不对齐:]
noquote(f2 <- formatSparseM(m,align="r"))
stopifnot(f2 == fm | m == 0, dim(f2) == dim(m),
(f2 == ".") == (m == 0))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|