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

R语言 IRanges包 compact()函数中文帮助文档(中英文对照)

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

                                        Object compaction
                                         对象压实

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

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

Compacting an object is modifying its internal representation in order to reduce its size in memory.
压缩一个对象被修改其内部表示,以减少其在内存中的大小。


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


compact(x, check=TRUE, ...)

## Internal compact() support function. Not intended to be called
## directly:
xvcopy(x, start=NA, end=NA, width=NA, lkup=NULL, reverse=FALSE)



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

参数:x
For compact, the object to be compacted. compact accepts any R object. However, on most of them, compact won't do anything and will just return an object identical to x. See the Details section below.  For xvcopy, a SharedVector, XVector, SharedVector_Pool, or XRawList vector.  
对于compact,对象被压缩。 compact接受任何R对象。然而,其中大部分,compact不会做任何事情,只会返回一个对象相同的x。见下面的详细信息部分。 xvcopy的1 SharedVector,XVector,SharedVector_Pool,或XRawList向量。


参数:check
After compacting the individual slots of an S4 object, this argument is passed to `slot<-` when replacing the original value of a slot with the compacted value.  
压实后的S4对象的单个插槽,这个参数被传递给slot<-时更换插槽的原始值与压实值。


参数:...
Arguments to be passed to or from other methods.  
参数被传递到或从其他方法。


参数:start, end, width, lkup, reverse
For internal use.  
供内部使用。


Details

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

The internal reorganization of the object should be transparent to the user i.e. compact(x) should "look" the same as x, or, more precisely, x and compact(x) should be interchangeable anywhere in the user's code. However, because they have different internal representations, we generally don't expect identical(x, compact(x)) to be TRUE, even though most of the times they will, because there are only very few types of objects that compact actually knows how to reorganize internally.
内部重组对象的用户应该是透明的,即compact(x)应该x,或更准确地说,“x和compact(x)应该是相同的”看“随时随地在用户的代码互换。然而,因为他们有不同的内部表示,我们一般不指望identical(x, compact(x))是真实的,即使大部分的时间,他们会因为有compact其实知道的对象只有极少数的类型如何以内部重组。

compact is a generic function.
compact是一个通用的功能。

Here is how the default method works. By default compact(x) is obtained by compacting all the "components" in x. Only 2 kinds of objects are considered to have "components": lists (the components are the list elements), and S4 objects (the components are the slots). The other objects are not considered to have components, so, by default, compact does nothing on them. In particular, it does nothing on environments. Also the attributes of an object (other than the slots of an S4 object) are not considered to be "components" and therefore are not compacted.
下面是默认的方法是如何工作的。默认情况下,compact(x)得到密实x所有的“组件”。只有2种对象都被认为具有“组件”列表(组件列表元素),S4对象(组件插槽)。不考虑其他对象有组件,所以默认情况下,compact对他们一无所知。特别是,它确实对环境无关。对象的属性(一个S4对象的插槽除外)不认为是“组件”,因此不板结。

Note that, in the absence of specialized compact methods that actually know how to reorganize an object internally, the default method would visit the tree of all the components, sub-components, sub-sub-components etc of object x without actually modifying anything in x. So of course, specialized compact methods need to be defined for the objects that can *effectively* be compacted. Otherwise the compact function would be equivalent to the identity function!
请注意,在专门compact方法,根本不知道如何内部重组对象的情况下,默认的方法将访问树的所有组件,子组件,分次组件等对象x实际上不修改任何在x。当然,专门compact方法,可以有效*被压缩的对象必须定义。 compact功能,否则将是相当于identity功能!

At the moment, 2 specialized compact methods are defined (in addition to the default method): one for XVector objects, and one for XVectorList objects.
目前,2个专门compact方法定义(除了默认的方法):XVector对象,XVectorList对象之一。


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

An object equivalent to x but eventually smaller in memory.
对象相当于x但最终还是在内存较小。


作者(S)----------Author(s)----------


H. Pages



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

XVector-class, XVectorList-class, subseq, object.size, save
XVector级,XVectorList级,subseq,object.size,save


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


## We illustrate the use of compact() on an XInteger vector (XInteger[#说明使用紧凑()一个XInteger向量(XInteger]
## is one of the 3 concrete subclasses of the XVector virtual class):[#3混凝土的XVector虚拟类的子类)之一:]
x <- XInteger(500000, sample(500000))

## subseq() does NOT copy the data stored in an XVector object:[,#subseq()不复制在XVector对象中存储的数据:]
y <- subseq(x, start=41, end=60)
x@shared
y@shared  # same address[同一地址]
object.size(x)
object.size(y)  # same size[同样大小]

## compact() copies the data, but only the data actually "used" by 'y':[#紧凑()复制的数据,但数据实际上只有“拿来主义”,由“Y”:]
y0 <- compact(y)
y0@shared  # new address[新地址]
object.size(y0)  # much smaller now![较小的现在!]

## Compaction is particularly relevant when saving an object with[保存对象时,#压实尤其是有关]
## external references like 'y':[像Y#外部引用:]
yfile <- file.path(tempdir(), "y.rda")
save(y, file=yfile)
file.info(yfile)$size

y0file <- file.path(tempdir(), "y0.rda")
save(y0, file=y0file)
file.info(y0file)$size

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-2-5 14:06 , Processed in 0.019705 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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