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

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

[复制链接]
发表于 2012-2-16 19:37:55 | 显示全部楼层 |阅读模式
serialize(base)
serialize()所属R语言包:base

                                        Simple Serialization Interface
                                         简单的序列化接口

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

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

A simple low-level interface for serializing to connections.
一个简单的低层次的序列化接口连接。


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


serialize(object, connection, ascii, version = NULL, refhook = NULL)

unserialize(connection, refhook = NULL)



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

参数:object
R object to serialize.
R对象进行序列化。


参数:connection
an open connection or (for serialize) NULL or (for unserialize) a raw vector (see "Details").
一个开放的连接或(serialize)NULL(unserialize)原始向量(见“详细资料”)。


参数:ascii
a logical.  If TRUE, an ASCII representation is written; otherwise binary one.  The default is TRUE for a text-mode connection and FALSE otherwise. See also the comments in the help for save.
一个逻辑。如果TRUE,ASCII表示被写入,否则二进制的一个。默认是TRUE文本模式连接FALSE否则。也在save帮助的意见。


参数:version
the workspace format version to use.  NULL specifies the current default version (2).  Versions prior to 2 are not supported, so this will only be relevant when there are later versions.
使用工作区的格式版本。 NULL指定当前默认的版本(2)。 2之前的版本不支持,所以这只会是相关的,当有更高版本。


参数:refhook
a hook function for handling reference objects.
一个钩子函数处理参考对象。


Details

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

The function serialize serializes object to the specified connection.  If connection is NULL then object is serialized to a raw vector, which is returned as the result of serialize.
功能serialize指定连接object序列。如果connection是NULL然后object序列化到原始向量,它的serialize结果返回。

Sharing of reference objects is preserved within the object but not across separate calls to serialize.
共享的参考对象被保存的对象内,但不能跨serialize单独调用。

unserialize reads an object (as written by serialize) from connection or a raw vector.
unserialize读取serialize或原始向量的对象(connection书面)。

The refhook functions can be used to customize handling of non-system reference objects (all external pointers and weak references, and all environments other than namespace and package environments and .GlobalEnv).  The hook function for serialize should return a character vector for references it wants to handle; otherwise it should return NULL.  The hook for unserialize will be called with character vectors supplied to serialize and should return an appropriate object.
refhook功能,可用于自定义处理非系统的参考对象(所有外部指针引用和弱引用,命名空间和包环境以外的所有环境和.GlobalEnv)。否则,它应该返回serializeNULL应该返回一个引用字符的向量,它要处理的钩子函数。将被调用提供unserialize应该返回一个合适的对象的特征向量的钩serialize“。

For a text-mode connection, the default value of ascii is set to TRUE: only ASCII representations can be written to text-mode connections and attempting to use ascii = FALSE will throw an error.
对于一个文本模式的连接,ascii的默认值设置TRUE,只有ASCII表示可以写入到文本模式连接,并试图用ascii = FALSE会抛出一个错误。

The format consists of a single line followed by the data: the first line contains a single character: X for binary serialization and A for ASCII serialization, followed by a new line.  (The format used is identical to that used by readRDS.)
单行数据的格式包括:第一行包含一个单一的字符:X二进制序列化和A为ASCII序列,其次是一个新行。 (使用的格式是相同readRDS的。)


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

For serialize, NULL unless connection = NULL, when the result is returned in a raw vector.
serialize,NULL除非connection = NULL,当结果返回原始向量。

For unserialize an R object.
unserializeR对象。


警告----------Warning----------

These functions have provided a stable interface since R 2.4.0 (when the storage of serialized objects was changed from character to raw vectors).  However, the serialization format may change in future versions of R, so this interface should not be used for long-term storage of R objects.
这些功能提供了一个稳定的接口2.4.0(序列化对象的存储改为从字符到原始向量时)由于R。然而,序列化格式可能改变未来的R版本,所以这个接口不应该被用于R对象的长期存储。

A raw vector is limited to 2^31 - 1 bytes, but R objects can exceed this and their serializations will normally be larger than the objects.
一个原始矢量2^31 - 1字节是有限的,但R对象可以超过这个序列化通常会大于对象。


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

saveRDS for a more convenient interface to serialize an object to a file or connection.
saveRDS对象序列化到一个文件或连接更方便的界面。

save and load to serialize and restore one or more named objects.
save和load序列化和还原一个或多个命名的对象。

The "R Internals" manual for details of the format used.
“R内部手册所用的格式的详细信息。


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


x <- serialize(list(1,2,3), NULL)
unserialize(x)

## see also the examples for saveRDS[#看到的例子saveRDS]

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-24 21:05 , Processed in 0.024101 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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