externalFormats(Matrix)
externalFormats()所属R语言包:Matrix
Read and write external matrix formats
读写外部矩阵格式
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Read matrices stored in the Harwell-Boeing or MatrixMarket formats or write sparseMatrix objects to one of these formats.
阅读在哈威尔波音或MatrixMarket的格式存储的矩阵或写sparseMatrix对象,以这些格式之一。
用法----------Usage----------
readHB(file)
readMM(file)
writeMM(obj, file, ...)
参数----------Arguments----------
参数:obj
a real sparse matrix
一个真正的稀疏矩阵
参数:file
for writeMM - the name of the file to be written. For readHB and readMM the name of the file to read, as a character scalar. The names of files storing matrices in the Harwell-Boeing format usually end in ".rua" or ".rsa". Those storing matrices in the MatrixMarket format usually end in ".mtx". Alternatively, readHB and readMM accept connection objects.
writeMM - 要写入的文件名。 readHB和readMM作为一个字符标,读文件的名称。存储在哈威尔波音格式的矩阵文件的名称通常结束在".rua"或".rsa"。在那些在MatrixMarket格式存储矩阵通常在".mtx"结束。另外,readHB和readMM接受连接对象。
参数:...
optional additional arguments. Currently none are used in any methods.
可选的附加参数。目前没有使用任何方法。
值----------Value----------
The readHB and readMM functions return an object that inherits from the "Matrix" class. Methods for the writeMM generic functions usually return NULL and, as a side effect, the matrix obj is written to file in the MatrixMarket format (writeMM).
readHB和readMM函数返回一个对象,从"Matrix"类继承。 writeMM通用功能的方法通常返回NULL,作为一个副作用,矩阵obj写在MatrixMarket格式(writeMM)的file。
注意----------Note----------
The Harwell-Boeing format is older and less flexible than the MatrixMarket format. The function writeHB was deprecated and has now been removed. Please use writeMM instead.
哈威尔波音格式是老年人和比MatrixMarket格式不够灵活。函数writeHB被废弃,现在已被删除。请使用writeMM代替。
A very simple way to export small sparse matrices S, is to use summary(S) which returns a data.frame with columns i, j, and possibly x, see summary in sparseMatrix-class, and an example below.
出口小的稀疏矩阵的一个非常简单的方法S,是使用summary(S)返回一个data.frame列i,j,并有可能<X >,看到xsummary,下面一个例子。
参考文献----------References----------
举例----------Examples----------
str(pores <- readMM(system.file("external/pores_1.mtx",
package = "Matrix")))
str(utm <- readHB(system.file("external/utm300.rua",
package = "Matrix")))
str(lundA <- readMM(system.file("external/lund_a.mtx",
package = "Matrix")))
str(lundA <- readHB(system.file("external/lund_a.rsa",
package = "Matrix")))
## Not run: [#无法运行:]
## NOTE: The following examples take quite some time[#注意:下面的例子,需要一段时间]
## ---- even on a fast internet connection:[#----即使是在高速互联网连接:]
if(FALSE) # the URL has been corrected, but we need an un-tar step![URL已被纠正,但我们需要一个非焦油的一步!]
str(sm <-
readHB(gzcon(url("http://www.cise.ufl.edu/research/sparse/RB/Boeing/msc00726.tar.gz"))))
str(jgl009 <-
readMM(gzcon(url("ftp://math.nist.gov/pub/MatrixMarket2/Harwell-Boeing/counterx/jgl009.mtx.gz"))))
## End(Not run)[#结束(不运行)]
data(KNex)
writeMM(KNex$mm, "mmMM.mtx")
## very simple export - in triplet format - to text file:[#非常简单的导出 - 三胞胎格式 - 文本文件:]
data(CAex)
s.CA <- summary(CAex)
message("writing to ", outf <- tempfile())
write.table(s.CA, file = outf, row.names=FALSE)
## and read it back -- showing off sparseMatrix():[#读回 - 炫耀sparseMatrix():]
dd <- read.table(outf, header=TRUE)
mm <- do.call(sparseMatrix, dd)
stopifnot(all.equal(mm, CAex, tol=1e-15))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|