relist(utils)
relist()所属R语言包:utils
Allow Re-Listing an unlist()ed Object
允许重新上市不公开()ED对象
译者:生物统计家园网 机器人LoveR
描述----------Description----------
relist() is an S3 generic function with a few methods in order to allow easy inversion of unlist(obj) when that is used with an object obj of (S3) class "relistable".
relist()是一个S3为了几个方法的通用功能,便于反演unlist(obj)时,与对象obj(三)类"relistable"。
用法----------Usage----------
relist(flesh, skeleton)
## Default S3 method:[默认方法]
relist(flesh, skeleton = attr(flesh, "skeleton"))
## S3 method for class 'factor'
relist(flesh, skeleton = attr(flesh, "skeleton"))
## S3 method for class 'list'
relist(flesh, skeleton = attr(flesh, "skeleton"))
## S3 method for class 'matrix'
relist(flesh, skeleton = attr(flesh, "skeleton"))
as.relistable(x)
is.relistable(x)
## S3 method for class 'relistable'
unlist(x, recursive = TRUE, use.names = TRUE)
参数----------Arguments----------
参数:flesh
a vector to be relisted
矢量被relisted的
参数:skeleton
a list, the structure of which determines the structure of the result
一个列表,其结构决定了结果的结构
参数:x
an R object, typically a list (or vector).
R对象,通常是一个列表(或向量)。
参数:recursive
logical. Should unlisting be applied to list components of x?
逻辑。应unlisting应用列出x组件?
参数:use.names
logical. Should names be preserved?
逻辑。应名被保留吗?
Details
详情----------Details----------
Some functions need many parameters, which are most easily represented in complex structures, e.g., nested lists. Unfortunately, many mathematical functions in R, including optim and nlm can only operate on functions whose domain is a vector. R has unlist() to convert nested list objects into a vector representation. relist(), it's methods and the functionality mentioned here provide the inverse operation to convert vectors back to the convenient structural representation. This allows structured functions (such as optim()) to have simple mathematical interfaces.
有些功能需要很多的参数,这是最容易在复杂的结构,例如,嵌套列表。不幸的是,许多数学函数在R,包括optim和nlm只能操作功能,其域名是一个向量。 R有unlist()嵌套列表对象转换成一个向量表示。 relist(),它的方法,这里提到的功能提供的逆运算,转换向量方便的结构示意图。这使得结构功能(如optim())有简单的数学接口。
For example, a likelihood function for a multivariate normal model needs a variance-covariance matrix and a mean vector. It would be most convenient to represent it as a list containing a vector and a matrix. A typical parameter might look like
例如,为一个多元正态模型的似然函数需要一个协方差矩阵和均值向量。这将是最方便的来代表它作为一个包含向量和矩阵的列表。一个典型的参数可能看起来像
值----------Value----------
an object of (S3) class "relistable" (and "list").
一个对象(三)类"relistable"("list")。
作者(S)----------Author(s)----------
R Core, based on a code proposal by Andrew Clausen.
参见----------See Also----------
unlist
unlist
举例----------Examples----------
ipar <- list(mean=c(0, 1), vcov=cbind(c(1, 1), c(1, 0)))
initial.param <- as.relistable(ipar)
ul <- unlist(initial.param)
relist(ul)
stopifnot(identical(relist(ul), initial.param))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|